summaryrefslogtreecommitdiff
path: root/spec/unit/pops/evaluator
AgeCommit message (Collapse)AuthorFilesLines
2014-10-06Merge branch 'pr/3136' into stableAndrew Parker1-5/+5
* pr/3136: (PUP-3364) Improve the error message for numeric resource titles
2014-10-06(PUP-3364) Improve the error message for numeric resource titlesHenrik Lindberg1-5/+5
This improves the error message when a numeric resource title is used in a resource reference, or when a numeric attribute name is referenced. The message used to be too generic, and used internal Ruby types instead of puppet types in the message string.
2014-09-30(PUP-3365) Change 3x deep map of undef to only do surface mapHenrik Lindberg1-0/+25
This changes the mapping of arguments to 3x function calls to not map undef to empty strings except at the surface level. Other mappings are still done as they are required for frozen strings, and values having a type that is not supported by the 3x functions.
2014-08-11(PUP-2972) Remove += and -=Andrew Parker2-113/+4
Previously the future parser supported += and -=. += was very similar to the same operator that is in the current parser, but with a few differences to make it consistent with the rest of the language. The += operator no longer performed string concatenation and instead acted like $a = $a + $b. The -= operator was added to complete the set of operators available. However, many people have been confused by these operators (even as they exist in the current parser): * It looks like mutation, but the language does not have mutation * It looks like += from other languages, but doesn't behave like them * Shadowing a variable is something that needs to be explicit, otherwise it becomes confusing. This removes += and -= from the future parser. They are still parsed, but the validation step will issue errors if they are encountered.
2014-08-01(PUP-2898) Add 4x style resource expressionsHenrik Lindberg1-1/+2
This changes the following: * Assignment has lower precedence than resource expressions * Local defaults are supported in resource instantiation expressions * A Resource body may have a new expression AttributesOperation that must evaluate to a hash. * Stricter validation of resource titles * Changes to TreeModelDumper wrt how BlockExpression is rendered (to improve debugging output). As a consequence many tests needed adjustments. * Tests that previously passed have been modified because of stricter validation. This also includes maintenance. Removing dead code/fixing stale comments and documentation.
2014-07-27(maint) Remove extra abstraction PAbstractType - change to PAnyTypeHenrik Lindberg1-1/+1
Since all types now are PAnyType, there is no need to have an extra abstratin called PAbstractType, it just adds level in the ancestor hierarchy that needs to be consulted for methods, one extra step to go when checking is_a? against PAbstractType instead of PAnyType, etc.
2014-07-08Merge branch 'pr/2819'Andrew Parker1-2/+1
* pr/2819: (maint) Remove biff setting and related code (PUP-2858) Remove evaluator setting (PUP-2858) Remove duplicated testing (evaluator = 'current') (PUP-2858) Refactor binder to use ne evaluator (PUP-2858) Remove the 3_1 checker and its factory (PUP-2858) Refactor EvaluatingParser::Transitional to EvaluatingParser (PUP-2858) Remove use of Puppet[:evaluator] from the code base (PUP-2858) Deprecate the use of Puppet[:environment] == current (PUP-2858) Remove e_parser adapter support Conflicts: spec/integration/node/environment_spec.rb Closes #2819
2014-07-07(PUP-2825) Refactor Ruby[type_name] type to Runtime[ruby, type_name]Henrik Lindberg1-2/+2
This changes the type Ruby[class_name] to the more generic Runtime[ruby, runtime_type_name] to avoid squatting on open set of names for potential runtimes which may clash with managment of the same runtime via a Puppet class or define. After this change, all references to Ruby[name] should be replaced with Runtime[ruby,name].
2014-07-02(PUP-2858) Refactor EvaluatingParser::Transitional to EvaluatingParserHenrik Lindberg1-1/+1
This merges the behavior of the Transitional subclass of the EvaluatingParser into the main class, as the hybrid solution is no longer a supported alternative. As a consequence, all references to the Pops::Parser::EvaluatingParser::Transitional has been changed to just Pops::Parser::EvaluatingParser. This commit alters no behavior.
2014-07-02(PUP-2858) Remove use of Puppet[:evaluator] from the code baseHenrik Lindberg1-1/+0
This removes all usage of Puppet[:evaluator] from the code base since it is (in this version) enough to check if Puppet[:parser] is 'future' as the future evaluator is always used.
2014-06-30(PUP-480) Change -= eval to assign nil instead of :undef for no resultHenrik Lindberg1-1/+1
2014-06-30(PUP-480) Change name to assert_no_undefHenrik Lindberg1-9/+9
Changes the name of die_undef_die test assertion function to assert_no_undef.
2014-06-30(PUP-480) Put the nail in :undef's coffinHenrik Lindberg1-0/+29
This changes the evaluation of a LiteralUndef to nil from :undef. As a consequence, there were minor adjustments needed to the Closure's call_by_name support to get the correct semantics for "missing" parameters. Tests are also added to ensure that :undef does not sneak into arrays or hashes in the 4x function API. This commit contains a cheat for epp and inline_epp functions as they need to receive their arguments without transformation. When that is fixed (PUP-2845) the cheat in runtime3_support#call_function() should be removed. :undef is still used in the "puppet/pops" section of the code (mainly for reasons of transforming to 3x, and if :undef symbols leak from 3x.)
2014-06-27Merge pull request #2789 from hlindberg/PUP-1811_in-set-match-varsAndrew Parker1-0/+13
(PUP-1811) Make 'in' set match vars when regexp is used to match
2014-06-23Merge pull request #2700 from ↵Andrew Parker1-0/+14
hlindberg/PUP-2663_allow-unary-plus-minus-string-numeric-conversion (PUP-2663) Allow unary plus/minus string numeric conversion
2014-06-24(PUP-2663) Adjust regexp to only match complete string, and not \nHenrik Lindberg1-0/+5
\s includes newline when ^$ is used. ^$ skips leading and trailing optional matches \A\z does not skip as they force matching of strings start/end
2014-06-20(PUP-1811) Add tests for regexp search in array setting match varsHenrik Lindberg1-1/+3
2014-06-20(PUP-1811) Set regexp match vars on regexp match using in operatorHenrik Lindberg1-0/+11
2014-06-19(PUP-2787) Rename Object Type to AnyHenrik Lindberg1-2/+2
This renames the top most type in the type system to Any from the name Object. This is done because the word Object carries connotations of "Object Oriented Programming" that simply adds confusion about how puppet works. This commit is basically a rename refactoring.
2014-06-17(maint) Remove dead test codeHenrik Lindberg1-3/+0
2014-06-14(maint) Add leaky local scope testsHenrik Lindberg1-0/+33
This adds tests that local and match scope handling is corrent and does not leak variable bindings.
2014-06-14(PUP-2755) Move iterative functions to the new APIHenrik Lindberg1-18/+22
This moves all the iterative functions to the 4x function API. Functions are now simpler to read. A shared utility module was created for repeated asserts. While testing it was clear that it is difficult to use Puppet.lookup(:loaders), and the evaluator was changed to get the loaders via the compiler instead. The evaluator tests are changed to make use of the simplified handling of the loaders. The tests for the functions that have moved, were also moved, but are unchanged in what they test.
2014-06-12(maint) Remove optional_objectAndrew Parker1-1/+1
Object is now the top class and so there is no need to use Optional[Object] everywhere. This removes the type factory method optional_object and replaces all occurrances with just object. It also updates all of the uses of Optional[Object] to use just Object.
2014-06-12(PUP-514) Improve testing of typed parametersHenrik Lindberg2-73/+0
This improves testing of typed parameters, and the ivolved tests in general. One test moved from being an evaluation test (it only tested parsing). Iterative function testing changed to use better matchers.
2014-06-12(PUP-514) Improve/add tests for typed parameters define/classHenrik Lindberg1-28/+3
2014-06-12(PUP-514) Add support for opt-in typing of define/class parametersHenrik Lindberg2-2/+8
This makes define and class parameters support optionally typed parameters when using the future parser. The type expressions are evaluated by the Pops Bridge when parameters are transformed t 3x. The 3x parameters are not aware of type information (they are encoded as arrays), and changes to all the logic that deals with parameters turned on to not be a good design. The resource type and resource is instead made aware of the opt-in types via a separate param-name to type map that it applies in the validation step that was already performed.
2014-06-12(PUP-514) Add test for validation of 'captures rest' in lambdasHenrik Lindberg1-1/+17
2014-06-12(PUP-514) Add validation and test of 'captures-last' parametersHenrik Lindberg1-0/+79
This validates that only functions may have captures-last, and that it may only be placed last amon the parameters.
2014-06-06Merge pull request #2689 from hlindberg/PUP-2514_no-type-search-in-stringJosh Partlow1-0/+1
(PUP-2514) Remove ability to search for String type in String.
2014-06-06Merge pull request #2665 from hlindberg/PUP-1807_empty-string-is-the-truthAdrien Thebo3-7/+10
(PUP-1807) empty string is the truth
2014-05-27(PUP-2663) Allow string to contain leading sign in numeric conversionHenrik Lindberg1-0/+9
This makes it possible to use an unary +/- in a string. The sign of the converted value abides by the unary string sign. White space is allowed around the sign, and at the end of the string. '+ 2' + '- 2' == 0 This is of value when dealing with original data in string form that needs to be converted. Without this it is especially difficult to pass a negative value around in string form.
2014-05-23(PUP-2514) Remove ability to search for String type in String.Henrik Lindberg1-0/+1
While philosophically true, a String consists of a number of substrings, it is not very meaningful to support only the ability to assert that. In order to be useful it would need to answer a much wider variety is Enum[red, blue, green] in "it was blue, orange, and red", is there a String of 1-5 characters in length inside the string "1234" etc. This commit removes the naive support for String/Data-type search in String as it is more confusing than helpful. If we later find it to be of value, a more elaborate implementation is needed.
2014-05-23(PUP-2642) Make default in selector be out of band, raise error nomatchHenrik Lindberg1-2/+8
This makes the selector expression in the future evaluator have the same semantics as the 3.6.1 current evaluator. The future evauator did not process default out of band, and did not raise an error when there was no match. This fixes both problems.
2014-05-18(PUP-1807) Add tests cases for undef equality checksHenrik Lindberg1-4/+7
This adds checks that future evaluator treats '' != undef. (It already did this, but tests were missing).
2014-05-18(PUP-1807) Change empty string to be "truthy"Henrik Lindberg2-3/+3
An empty string is now interpreted as a "true" value. It used to represent a false value. This representation is only in the future evaluator. Values are still transformed when calling the 3x function API (it expect undef to be encoded as empty string). This also takes place when transforming to the 3x catalog.
2014-05-16Merge remote-tracking branch 'upstream/stable'Josh Partlow2-0/+16
* upstream/stable: (PUP-2568) Remove unnecessary calls (maint) Reorder code to increase clarity (PUP-2581) Make illegal names interchangeable to legal variable work (PUP-2568) Downcase class name before validating Conflicts: lib/puppet/pops/parser/eparser.rb Rebuilt eparser.
2014-05-16Merge pull request #2661 from ↵Josh Partlow1-0/+10
hlindberg/pup-2581_interpolating-expression-of-bad-name (PUP-2581) Make illegal names interchangeable to legal variable in interpolation
2014-05-16(PUP-2581) Make illegal names interchangeable to legal variable workHenrik Lindberg1-0/+10
In interpolation when using expression mode ${} and having an illegal name (e.g. _x) that resulted in a syntax error as the _x got translated to a STRING token (a bare word not being a name). The interpolation logic could then not transform it into a (valid) variable expression (i.e. $_x). The change is to let the lexer emit a WORD token for the illegal NAME. The interpolation then changes that to a VARIBLE if it is the only expression. If the WORD token escapes into the grammar, it is equivalent to having used a quoted string in the source text. Note that WORD only accepts unqualified input, anything with a : that is not a valid NAME is still flagged as an error. Thus _x::y, x::_y are both illegal NAME.
2014-05-15(PUP-2568) Downcase class name before validatingAndrew Parker1-0/+6
Previously the check for a valid name was done against the raw input, however it later downcased the name and used that form. This order caused Class['A'] to be an error, which isn't desired (at least not until PUP-1810 is taken care of). By just changing the order of operations capital letters are once again allowed.
2014-05-09Merge pull request #2623 from ↵Andrew Parker1-1/+58
jpartlow/issue/master/pup-488-add-tests-for-resource-meta-parameter-access (PUP-488) Add specs fur future Resource parameter/metaparameter access
2014-05-08(PUP-2240) Add support for splat in case and selector expressions.Henrik Lindberg1-0/+5
This functionality was missing from the original work on supporting the splat (unfold operator).
2014-05-07(PUP-488) Add specs fur future Resource parameter/metaparameter accessJosh Partlow1-1/+58
This is just adding a little additional spec coverage for the future parser Resource[foo][attribute] syntax where attribute is either a parameter or a metaparameter. It also checks some virtual/realized/exported variations. From debugging, it appears that the only values being accessed during evaluation are those either set directly on the Puppet::Parser::Resource instance's Puppet::Parser::Resource::Params, or the default Puppet::Parser::Resource::Params which have been set in the current or parent scopes during evaluation of a Puppet::Pops::Model::ResourceDefaultsExpression for the given resource type. No attempt is made to lookup the type class's defined parameter defaults.
2014-05-06Merge pull request #2588 from hlindberg/pup-2287_lambda-default-always-ovrridesJosh Partlow1-0/+40
(PUP-2287) Fix lambda param with default is always choosen
2014-05-06Merge pull request #2532 from hlindberg/pup-2240_unfold-arrayJosh Partlow1-1/+23
(PUP-2240) Add unfold of array using splat unary * operator
2014-05-05(PUP-957) Remove special meaning of Regexp[r] in =~ !~ expressions.Henrik Lindberg1-1/+1
There are several issues with the previously implemented support where a parameterized Regexp was a stand in for a real regular expression: * The match variables where not set (and would be difficult to return in general since Regexp's and Patterns can be nested in other types). * Blurry line between what a Regexp type is, and String since Regexp[r] produces a RegularExpression Type, not a Regexp instance. This simply removes the special handling. A user can still use: * Regexp (/..../) * A String - transforms to a Regexp * Pattern[p] type (since it is a real subtype of String)
2014-04-27(maint) Fix creation of LoadersAndrew Parker1-1/+1
This line of code missed the update to how Loaders are created because it was done on a different branch.
2014-04-27(maint) Update test using old style initialization of loadersHenrik Lindberg1-1/+1
The API for creating loaders was changed (now requiring an environment). This updates the logic that used the old API.
2014-04-27(PUP-2287) Fix lambda param with default is always choosenHenrik Lindberg1-0/+40
This fixes the problem that a lambda parameter with a default always was choosen even if a value was given for the parameter. The expected behavior for function calls is that only truly missing (non given) arguments are subjects to default value replacement, not if a value is nil or undef. (This because functions are call by position, and not call by name as for defines and classes). Thus all nil/undef values are treated as any other value. One test for the map function relied on the now fixed bug and it has been marked pending, as it should be updated once the map function has been transitioned to the new function API. (Where undef is not transformed to empty string).
2014-04-24(PUP-2240) Fix failing test (hash order ruby 1.8.7)Henrik Lindberg1-1/+7
2014-04-24(PUP-2240) Add unfold of array using splat unary * operatorHenrik Lindberg1-1/+17
This adds the ability to unfold values into individual parameters and entries in lists the same way as this is done in Ruby.