summaryrefslogtreecommitdiff
path: root/spec/unit/pops
AgeCommit message (Collapse)AuthorFilesLines
2014-06-27(maint) Fix Enum / Variant assignabilityHenrik Lindberg1-1/+6
The type calculator did not correctly compute assignability for an Enum when assigning a Variant type. Now, all variants are checked if they are assignable to the enum type.
2014-06-27(maint) Fix Pattern / Variant Type assignabilityHenrik Lindberg1-0/+4
This fix corrects Pattern.assignable?(Variant) which was not correctly supported in the type calculator. (It gave up if t2 was not a String or an Enum). Now, if t2 is a Variant, the check recurses to the types described by the enum.
2014-06-26(PUP-2682) Allow trailing comma after node matchesHenrik Lindberg1-0/+4
This adds the ability to have a trailing comma after the last match in a node expression.
2014-06-26(PUP-2654) Capitalize each segment of a resource type "label"Henrik Lindberg1-0/+4
When a Resource type is stringified it selects the short notation (e.g. Fee::Foo) over the longer (e.g. Resource[Fee::Foo]), and when doing so it should output each segment of the FQN with a capital letter. The current implementation only capitalizes the initial letter (e.g. Fee::foo::fum). This fixes the implementation of TypeCalculator.string_PResourceExpression to capitalize all segments.
2014-06-25(PUP-2833) Make all types inherit PAnyTypeHenrik Lindberg1-2/+12
Some types inherited PAbstractType (to indicate they where not concrete). This just causes confusion when using the Ruby API to check if a Type is PAnyType. This makes all types inherit from PAnyType (which is the only type inheriting from PAbstractType).
2014-06-24(maint) Remove dead codeHenrik Lindberg1-2/+1
2014-06-24(PUP-2831) Make Puppet work with RGen 0.7.0Henrik Lindberg1-4/+7
This updates the Gemfile to use RGen 0.7.0 (optionally). In RGen 0.7.0 containment now works as specified, if something is contained more than once, it moves to the last container that contains it (by removing it as contained from all other containers). This caused problems in the Function API where the block default Callable type was reused for all signatures (and thus moved). There were also problems in tests where the same type instances was contained in multiple locations. This fixes these to use distinct instances.
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-23Merge pull request #2713 from hlindberg/PUP-2703_make-tag-into-statementAndrew Parker1-1/+1
(PUP-2703) Make 'tag' be a statement function
2014-06-23(PUP-2807) Add output of containing scope for log functionsHenrik Lindberg1-0/+6
The log functions in 3x outputs th name of the containing scope (for notice etc.). The reimplemented methods for the 4x function API did not include this behavior. Now, the calling scope is passed to the Logging utility to be output the same way as for 3x.
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-18Merge pull request #2780 from hlindberg/PUP-2787_rename-Object-AnyAndrew Parker3-24/+24
(PUP-2787) Rename Object Type to Any
2014-06-19(PUP-2787) Rename Object Type to AnyHenrik Lindberg3-24/+24
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-18Merge pull request #2778 from hlindberg/PUP-2758_micro-benchmarksAndrew Parker2-0/+63
(PUP-2758) Add micro (and other) benchmarks for future parser/evaluator
2014-06-17(maint) Correct typo in loader helper class and add testsHenrik Lindberg2-0/+63
Loading the same function multiple times from modules caused an error because of a typo in NamedEntry. This adds tests for the helper classes basic functionality, and adds tests that loaders indeed can load a function more than once. This also corrects error handling (yet another typo) when a function was redefined (the wrong method was called).
2014-06-17(PUP-2727) Make new keywords acceptable as attribute names.Henrik Lindberg1-0/+19
Puppet allows keywords as attribute names in defines and parameterized classes. This was missing for the added keywords: * FUNCTION * ATTR * PRIVATE * TYPE Which caused a clash with existing types. This commit adds the new keywords to the list of accepted words in the grammar.
2014-06-17Merge branch 'pr/2765'Andrew Parker1-18/+52
* pr/2765: (PUP-2755) Mark function stubs as rvalue (PUP-2791) Update docs for EPP syntax (maint) Fix stylistic issues from review of PUP-2755 (PUP-2755) Remove special handling of iterative functions / cleanup (maint) Fix stylistic issues from review (maint) Remove dead test code (maint) Add 3x function doc stub for 4x function with (maint) Update function 'with's documentation with an example (maint) Add 3x function doc stub for 4x function slice (maint) Add 3x function doc stub for 4x function reduce (maint) Add 3x function doc stub for 4x function match (maint) Add 3x doc function stub for 4x function map (maint) Add 3x function doc stub for 4x function filter (maint) Add 3x function doc stub for 4x function each (maint) Add doc stub for 4x function assert_type (PUP-2755) Fix issues after changes from PUP-514 (maint) Add leaky local scope tests (PUP-2755) Move iterative functions to the new API (PUP-1057) Remove the function stubs for collect and select
2014-06-17(maint) Remove dead test codeHenrik Lindberg1-3/+0
2014-06-16(maint) Disable future parser warnings based on :disable_warningsJosh Partlow1-0/+170
Work on PUP-2650 missed that the future parser has a separate method of handling deprecation warnings. This changes IssueReporter to muzzle deprecations when 'deprecations' is in Puppet[:disable_warnings]. It also adjusts the max_warnings/deprecations counts to be one-based, so a setting of Puppet[:max_warnings] = 4 emits at most 4 warnings per manifest from future parser. A setting of 0 blocks the warnings altogether. Adds specs for the current behavior.
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 Parker2-7/+5
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(maint) Remove duplicate testAndrew Parker1-9/+0
2014-06-12(maint) Improve tests for slurp on define/classAndrew Parker1-2/+2
The tests for define and class rejecting `*` parameters put another parameter after the one specified with `*`. This created an ambiguity in the test for why it is failing, since `*` is not allowed before any other parameters. Since the assertion is that define and class simply cannot have `*` parameters, the better test is to have a single parameter with a `*`.
2014-06-12(PUP-514) Add tests for lambdasAndrew Parker1-0/+9
The work so far has not been able to deal with type checking lambdas. This adds tests for the conditions that will need to be handled for lambdas to properly type check their arguments. Currently none of these new tests pass.
2014-06-12(PUP-514) Fix assignability of 0 min TuplesAndrew Parker1-0/+37
The assignability logic didn't consider an empty Tuple (Tuple) to be assignable to a Tuple of min size 0 (Tuple[Object, 0, default]). This prevented the case of a Callable that represented with only varargs from being called with no arguments (Callable[Object, 0, default], Tuple). The mistake was that after the check that the sizes of the tuples were compatible, it then used the *max* of the two tuple's type parameters to determine if the two are compatible. However, only the list of types in the right hand side tuple matter in determining assignability.
2014-06-12(PUP-514) Improve testing of typed parametersHenrik Lindberg2-9/+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(maint) Remove pending tests for parsing functions in puppetHenrik Lindberg1-32/+0
2014-06-12(PUP-514) Add support for opt-in typing of define/class parametersHenrik Lindberg3-2/+12
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-12(PUP-514) Add test for parsing of typed parametersHenrik Lindberg1-0/+28
This updates the tree dumper to dump parsed type information for parameters.
2014-06-09(PUP-2693) Fix length calculation for sq-stringHenrik Lindberg1-0/+10
The calculation of string length was done wrong for dingle quoted string resulting in negative lengths.
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-30(PUP-2703) Make 'tag' be a statement functionHenrik Lindberg1-1/+1
Tag function should not require parentheses.
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-23Merge pull request #2685 from hlindberg/PUP-2314_assert-type-lambda-and-messageJosh Partlow1-0/+1
(PUP-2314)(PUP-2632) Fix assert_type's API
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-21(PUP-2632) Make Type be subtype of ObjectHenrik Lindberg1-0/+1
Without this change, a reference to "any" must be written Optional[Variant[Type, Object]] which is quite horrible. There is no harm in making Type an Object since that is the most abstract type as seen from the Puppet Programming Language.
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 Partlow3-2/+26
* 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 Partlow2-2/+20
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 Lindberg2-2/+20
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.