summaryrefslogtreecommitdiff
path: root/spec/unit/pops
AgeCommit message (Collapse)AuthorFilesLines
2014-10-15(PUP-3401) Fix type calculations of "all Patterns"Henrik Lindberg1-0/+26
The type calculator did not correctly compute assignability for a non parameterized Pattern. Such a Pattern is equal to "any string", and is thus assignable from any other Pattern, Enum or String. This was missing in the calculator and this resulted in Pattern neither being equal to, less than, or greater than parameterized patterns.
2014-10-10(PUP-3201) Treat :undef as PNilTypeAndrew Parker1-0/+4
For PUP-2857 :undef was changed from being a PNilType to a PRuntimeType. This stopped the undef literal in the language from being able to be assigned to Optional parameters. However, this only happened when the undef was the default expression for the parameter.
2014-10-09Merge pull request #3134 from hlindberg/PUP-3366_string-enum-type-calculationAndrew Parker1-0/+31
PUP-3366 Fix issues with string/enum type assignable calculations
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-10-03Merge pull request #3142 from ↵Andrew Parker1-0/+25
hlindberg/PUP-3365_remove-deep-undef-mapping-in-3x-func-api (PUP-3365) Change 3x deep map of undef to only do surface map
2014-10-03(PUP-3366) Correct comparisson of Enum > Enum[a]Henrik Lindberg1-0/+5
Comparissons involving an unparentesized Enum were not correct because an iteration with all? returns true if the set being enumerated is empty. This modifies the logic, and adds missing tests.
2014-10-03(PUP-3363) Make transformation of unparenthesized calls handle errorsHenrik Lindberg1-5/+20
This fixes problems when a user enters commas where they are not supposed to be. As a result, an expression will be parsed as being an argument list for an unparenthesized function call. The transformation logic for such calls did not take one case into account; a non call followed by an argument list. e.g: $a = 1,10 Which resulted in a strange AST model (a literal list with an assignment and a 10). This commit adds error checking and raising of an exception in the transformation which is caught by parser_support and formatted into an error - either about an illegal comma (when the LHS cannot possibly be a call at all (as in the above exampel), or a more elaborate message about that what could be a function call requires parentheses. In order to enable positioning of the error message on the first comma in the argumet list, the comma tokens were required in the expression list fed to the transformer. Subsequently these tokens must be filtered out by the transformation, and passed on in the raised exception (since the receiver would otherwise not know which token that caused the problem (it is nested inside the stucture it passes on to be transformed). Unparenthesized function calls are a very bad idea...
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-09-29PUP-3366 Fix issues with string/enum type assignable calculationsHenrik Lindberg1-0/+26
There were errors in the calculation of string/enum calculation. Basically Enum == String, if String is size constrained then Enum < String. This fixes this calculation. There were no tests for this, they are now added.
2014-09-10(PUP-3190) Improve readability of function creation logic.Henrik Lindberg1-1/+7
2014-09-08(PUP-3190) Don't assume puppet is in a lib dirAndrew Parker3-55/+42
The loaders previously assumed that any installation of puppet would be under a directory called lib. This holds true when running puppet from source (during development), or in some package cases, but is not generally true. This simplifying assumption was made so that the loading path for both puppet system extensions (built in functions) and module extensions could be loaded in the same manner: find the root of the extender and loading code from `lib/puppet/...`. This changes to loading to instead only assume that there is a `puppet` directory and not the name of the parent. This, however, forces the loader for modules to become specialized to only be able to find ruby extentions, because they are in the 'lib' directory, which is how the loader must now be configured.
2014-08-29Merge pull request #3024 from ↵Josh Partlow1-0/+9
hlindberg/PUP-3117_resource-expression-splat-rocket-alt (PUP-3117) Complete the Resource Expression implementation
2014-08-27(maint) Fix faulty issue ILLEGAL_NUMERIC_PARAMETER and validationHenrik Lindberg1-0/+9
There was a typo in the message that referenced a non existing variable. This was undetected because there was no test to cover this. When testing the expected behavior, it was found that the validation was not correct as it allowed parameters to have hexadecimal names, but not octal names. Now all numeric parameter names are disallowed (they cannot be used or addressed anyway).
2014-08-27(PUP-2349) Specify mode as an octal string consistently in spec manifest ↵Kylo Ginsberg1-35/+35
snippets In the puppet 4.0 parser, the file resource's mode property will be required to be a string containing an octal (or symbolic) representation of mode. For consistency then, this commit changes all cases where mode was specified as a Numeric to be a string containing an octal representation of mode (always prefaced with a 0, again for clarity and consistency).
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-04(PUP-2898) Specify terminal semicolon for resource bodiesJosh Partlow1-0/+9
There was a regression in the future parser in d25e462 which caused resources with multiple attributeless bodies constructed like this: file { '/foo':; '/bar':; } to fail because the future parser grammar was not allowing the terminal semicolon. The acceptance suite picked this up running with parser future. It slipped past specs because, even though we have a spec testing multiple attributeless resource bodies, it lacked a terminal semicolon. Henrik Lindberg figured out the minor egrammar fix here to correct the expression, and a test case is added to catch it in specs.
2014-08-01(PUP-2898) Add 4x style resource expressionsHenrik Lindberg6-85/+230
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-08-01(PUP-2898) Drop support for AST Transform of ResourcesHenrik Lindberg1-185/+0
The implementation no longer needs to transform resource expressions to 3x AST. This changes the transformer to raise an error if attempted. The spec test for resource transformation is also dropped. No new test added that transformer raises exceptions for resource transformation since all transformation eventually will be dropped.
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-27(PUP-2860) Remove future parser's old lexerHenrik Lindberg1-840/+0
The old (intermediate) lexer was still hanging around even if it was not being used. Cycles were also wasted on unit testing it. The new lexer "Lexer2" has been in use for quite some time and the old lexer is not useful even as a reference at this point. This speeds up both loading and unit testing.
2014-07-24(maint) Fix spec order issue for Travis CI.Peter Huene1-22/+24
Because of the order Travis runs specs, some environment caching issues were found that caused some specs to fail because they made the assumption that the production environment wasn't already in the cache. Thus, they relied on changing Puppet[:modulepath] to have an effect. The fix is to override the environments for these two specs and return an environment we know has the expected module path.
2014-07-17Merge pull request #2874 from adrienthebo/maint/master/update-rspecAndrew Parker1-1/+1
Maint/master/update rspec
2014-07-16(PUP-2824) Add errors for reserved parameter namesHenrik Lindberg1-0/+14
This adds validation of reserved parameter names; $name and $title that, if they are used will cause problems later in the production of a catalog. The implementation performs the checks as part of validation of the parsed puppet logic.
2014-07-15Merge pull request #2842 from hlindberg/PUP-2886_reserved-type-namesJosh Partlow1-0/+35
(PUP-2886) Add validation for reserved type names
2014-07-15(maint) Remove deprecated `.to_not raise_error(args)` callsAdrien Thebo1-1/+1
From RSpec: DEPRECATION: `expect { }.not_to raise_error(SpecificErrorClass, message)` is deprecated. Use `expect { }.not_to raise_error` (with no args) instead. This commit removes all args from `.to_not raise_error` expectations.
2014-07-15(PUP-2714) Support explicit creation of empty programHenrik Lindberg1-0/+16
An empty program (one without any expressions except "no-op") did not produce an instance of Model::Program. This is bad because it is of value to get the lexed/parsed model with line references for comment processing and other static analysis of the source. Now, an empty program will produce a Model::Program containing a single Model::Nop instruction. This instruction has offset at "EOF", and a length of 0 (thus, any comments in the input source are guaranteed to be placed before this nop.
2014-07-14Merge pull request #2755 from hlindberg/PUP-2693_length-of-sqstring-wrongJosh Partlow1-0/+10
(PUP-2693) Fix length calculation for sq-string
2014-07-14Merge pull request #2792 from hlindberg/PUP-2807_log-containing-scope-nameJosh Partlow1-0/+6
(PUP-2807) Add output of containing scope for log functions
2014-07-08Merge pull request #2802 from hlindberg/PUP-2831_use-rgen-0-7-0Andrew Parker1-5/+7
(PUP-2831) Make Puppet work with RGen 0.7.0
2014-07-08Merge branch 'pr/2819'Andrew Parker8-106/+7
* 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-08(maint) Remove biff setting and related codeAndrew Parker3-70/+4
The Biff setting is not one that we need in the 3.x series. The work that it was for was halted and will be picked up at a later date.
2014-07-08(PUP-2857) Add a type for default expression called Default.Henrik Lindberg3-13/+34
Before this change, the special value produced by a default expression was treated as a Ruby['Symbol'] (later changed to Runtime['ruby', 'Symbol']). This commit changes this to produce an instance of a new type called Default. The Default type is an Any, but is not assignable to anything else. This also removes the inference of :undef to PNilType (a.k.a Undef in the Puppet Language). The reason for this, now that :undef is never used by the evaluator. Thus, if someone were to return :undef, or have it in a data structure, the type calculator would falsely inferr it as an Undef / NilType. Now, instead, it will be inferred as a Runtime['ruby', 'Symbol'] and this makes it more clear to a user that they leaked an :undef in error. As a consequence several tests that used :undef needed to be changed.
2014-07-07(PUP-2825) Refactor Ruby[type_name] type to Runtime[ruby, type_name]Henrik Lindberg4-17/+20
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-07Merge pull request #2803 from hlindberg/PUP-2833_all-types-are-anyAndrew Parker1-2/+12
(PUP-2833) Make all types inherit PAnyType
2014-07-07Merge pull request #2821 from hlindberg/PUP-2794_callable_checkAndrew Parker2-8/+129
(PUP-2794) Change Callable to mean "can be called with"
2014-07-06(PUP-2886) Add validation for reserved type namesHenrik Lindberg1-0/+35
Before this it was possible to name classes and defines with words that are reserved by the type system (e.g. 'integer'), while the name is not a type (Integer is a type, but integer is not), the definitions will automatically create a resource type named with an upper case initial letter, and will thus be difficult to reference. For that reason it is better to error on these names statically.
2014-07-02(PUP-2858) Remove the 3_1 checker and its factoryHenrik Lindberg1-30/+0
This removes the Checker_3_1 and its factory from the code base. This hybrid checker contained less validation (less string) than the 4.0 checker and its main purpose was to fail expressions that could not be evaluated with the 3x AST based evaluation (such as -=). It is also not meaningful to continue its development as the new 4_0 checker is far better. If there is a later need to check for "backwards compatibility" to 3x, it is better to start fresh with a new copy of the 4_0 evaluator.
2014-07-02(PUP-2858) Refactor EvaluatingParser::Transitional to EvaluatingParserHenrik Lindberg4-4/+3
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 Lindberg2-2/+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-07-02(PUP-2794) Fix problem with check for >0 paramsHenrik Lindberg1-1/+8
There was a problem with the check for empty range, as the size of a range Integer[0,0] is not 0, but 1 (there is a 0 in the range). Also adds test to check that type parser produces a Callable with a Unit type when the range so requires.
2014-07-01(PUP-2794) Add an (internal) type called Unit and use in CallableHenrik Lindberg1-5/+38
This adds a type named Unit, that is an "undef of sort" in that it is assignable to anything, and anything can be assigned to it. This type is not exposed in the Puppet Language, and it is only used in Callables to describe that there is no type requirement on a parameter. (For cases where reflection of a given lambda is performed etc. or where the error raised when calling a block is an acceptable solution).
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-30Merge pull request #2815 from hlindberg/PUP-2845_move_epp_functionsAndrew Parker1-0/+24
(PUP-2845) Move epp functions
2014-06-30(PUP-2794) Change Callable to mean "can be called with"Henrik Lindberg1-2/+83
It is more meaningful to check that a Callable can be called with certain types (exact or more generic) than to check the reverse. This alters the meaning of Callable assignability so that a more generic Callable is accepted. While this seems counterintuitive from the perspective of the type system, it is the constraint that is expected as the constraint being expressed means "Must be callable with arguments of these types", and a more generic callable is just that. The current implementation got that wrong, and will actually accept callables that can in fact not be called. This also alters the assert_type function that declared that it would call a given block with Any, Any, when in fact it will call with Type, Type. Note, that a function that after this delares that it calls Callable[Any] will enforce that the given callable is Any. If the intent is to accept any callable, the type should be given as just Callable.
2014-06-27Merge branch 'pr/2810'Andrew Parker1-0/+4
* pr/2810: (maint) Extract constant for name separator (PUP-2654) Capitalize each segment of a resource type "label"
2014-06-27(maint) Fix problem with Enum subset not matching EnumHenrik Lindberg1-0/+15
This corrects a problem where Enum[a] was not assignable to Enum[a,b], since it is a subset, it should be assignable.
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