summaryrefslogtreecommitdiff
path: root/spec/unit/pops/evaluator/evaluating_parser_spec.rb
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 Parker1-8/+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-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 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 Lindberg1-1/+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) Add support for opt-in typing of define/class parametersHenrik Lindberg1-2/+6
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-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 Thebo1-1/+1
(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) Change empty string to be "truthy"Henrik Lindberg1-1/+1
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 Partlow1-0/+10
* 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-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-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.
2014-04-24(PUP-2317) Make future parser issue discontinuation error for importHenrik Lindberg1-0/+14
This makes the use of import statements raise an error. The implementation reinstates "import" as a statement function. (This is done by the factory when it finds a name followed by an expression list). Then, to raise the error, a function written with the function API called 'import' raises an error. This also introduced a way to raise errors based on the issue/acceptor system. This new error type is called Puppet::Pops::SemanticError. It is used to issue the discontinuation error. The error itself refers to the deprecation URL which points to the relevant documentation for manifest directory and import.
2014-04-21Merge pull request #2534 from hlindberg/pup-2190_lookup-meta-parameterJosh Partlow1-0/+6
(PUP-2190) Fix issue when there are no defaults (for meta params)
2014-04-17(maint) Fix comparison error float - stringHenrik Lindberg1-0/+1
The comparison used kind_of(), intead of kind_of?() Test added.
2014-04-14(PUP-2190) Fix issue when there are no defaults (for meta params)Henrik Lindberg1-0/+6
When looking up a metaparameter - Notify['foo'][tag], this failed when no tags had been set. The same problem would occur for any parameter that the resource api reported to be a vaid parameter but for which asking for its default did not return a Parameter.
2014-04-07(PUP-1964) Handle nil class parameter valueHenrik Lindberg1-0/+4
The problem was that nil was not transformed to undef for the result of a parameter default expression and nil was interpreted as value missing by the 3x class/define logic. This adds a transformation in the PopsBridge by introducing a new kind of bridging expression. Likewise, a transformation was needed back again to nil as the value was set in TypeCalculator when performing an inference and symbol :undef can not be used where a String is expected. It was also observed in PUP-1964 that the error that surfaced lacked location information. This was caused by the transformation of unparenthesized call, where the transformed call expression did not get location information set. Tests added for the two different problems. The factory method for recording position now also checks if the end_locateable is void of location information (which can happen in some transformations).
2014-03-06(PUP-30) Add tests for heredoc at parser and evaluator levelsHenrik Lindberg1-2/+70
This also fixes issues found by running the new tests and debugging them.
2014-02-28(PUP-1144) Improve handling of underscore in variable namesHenrik Lindberg1-0/+10
The last segment of a qualified variable name is allowed to start with an underscore. Previously this was only allowed for a single segment.
2014-02-04(PUP-1579) Rename the Literal type to ScalarHenrik Lindberg1-3/+3
Calling the type "Literal" was bad because it is used not only for literal values entered in source code, but naturally also for computed values. A commonly used name for these types is "Scalar". This commit changes "Literal" to "Scalar" everywhere: * class name PLiteralType => PScalarType * its label * factory methods "literal" => "scalar"
2014-01-17(PUP-1166) Add better error message when turning on strict_variablesHenrik Lindberg1-0/+6
When turning on --strict_variables without also using --future parser with the future evaluator, the raised error is an uncaught throw. Now the error message is "Undefined Variable".
2013-12-31(maint) Fix inconsistency when case option is a Type.Henrik Lindberg1-0/+7
The way the implementation worked made it impossible to differentiate between an instance and its type.