summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser/ast
Commit message (Collapse)AuthorAgeFilesLines
* Fixing ruby warning in definition testLuke Kanies2009-08-021-1/+1
| | | | Signed-off-by: Luke Kanies <luke@madstop.com>
* Implement node matching with regexesBrice Figureau2009-08-013-5/+73
| | | | | | | This patch enhance AST::HostName to support regexes, and modifies the parser to allow regex to be used as node name. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>]
* Make sure node are referenced by their namesBrice Figureau2009-08-011-1/+44
| | | | | | | | | This patch uses the unused AST::HostName as the only way to reference a node in the AST nodes array. The AST::HostName respect the hash properties of the underlying string, to keep the O(1) hash properties. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Enhance selector and case statements to match with regexpBrice Figureau2009-08-012-0/+299
| | | | | | | | | | | | | | | | | | | | | | | | | The case and selector statements define ephemeral vars, like 'if'. Usage: case statement: $var = "foobar" case $var { "foo": { notify { "got a foo": } } /(.*)bar$/: { notify{ "hey we got a $1": } } } and for selector: $val = $test ? { /^match.*$/ => "matched", default => "default" } Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #2033 - Allow regexp in if expressionBrice Figureau2009-08-012-0/+125
| | | | | | | | | | | | | | | | | | | This changeset introduces regexp in if expression with the use of the =~ (match) and !~ (not match) operator. Usage: if $uname =~ /Linux|Debian/ { ... } Moreover this patch creates ephemeral variables ($0 to $9) in the current scope which contains the regex captures: if $uname =~ /(Linux|Debian)/ { notice("this is a $1 system") } Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Add AST::Regex, an AST leaf node representing a regexBrice Figureau2009-08-011-1/+120
| | | | | | Add a regex rule (unused for the moment) to the parser. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Implement ephemeral scope variablesBrice Figureau2009-08-011-2/+2
| | | | | | | | | | Those variables have been created to be short lived and used mainly to define temporary special variables. They do not persist after a call to unset_ephemeral_var. Also Scope#set_ephemeral_from can be used to promote a regexp MatchData to ephemeral values. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #2422 & #2433 - make sure puppetdoc transform AST::Leaf boolean correctlyBrice Figureau2009-07-254-0/+49
| | | | | | | | | | AST nodes don't have a valid to_s that is producing a correct representation of said node. This patch adds some of the AST node to_s to produce correct values that can be used verbatim by puppetdoc to render the documentation. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Switching to LoadedCode from ASTSetLuke Kanies2009-07-051-6/+6
| | | | | | | | I also took the opportunity to clean up and simplify the interface to the parts of the parser that interact with this. Mostly it was method renames. Signed-off-by: Luke Kanies <luke@madstop.com>
* Make sure virtual and rails query use tags when tag are searchedBrice Figureau2009-06-061-0/+21
| | | | | | | | | | | | Up to now, when trying to match with tags: File<<| tag == 'value' |>> in fact we were querying parameters. Hopefully all the user tags are stored in parameters so it was working. But it wasn't possible to search on auto-tags (like class name). This patch makes sure searching by tag is done on tags both on the rails side and the resource side. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #2246 - Array tagged resources can't be collected or exportedBrice Figureau2009-06-061-2/+4
| | | | | | | | | | | | I don't know why we imposed the restriction that we shouldn't match with parameter containing arrays in exported mode. That doesn't seem right, as the produced rails query works fine with arrays. Note: the user tags are not stored in the rails database except under the special resource parameter tag. This also doesn't seem right. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Removed extra whitespace from end of linesIan Taylor2009-06-0610-49/+49
|
* Changed tabs to spaces without interfering with indentation or alignmentIan Taylor2009-06-062-16/+16
|
* Fix #1088 - part2 - Add rspec testsBrice Figureau2009-03-141-0/+63
| | | | Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fixed #1884 - exported defines are collected by the exporting hostLuke Kanies2009-02-111-3/+16
| | | | | | | | | | | | | | | | | | This was caused by the fix to #1472. That fix unexported any resources collected from the local catalog. The crux of this fix is that it separates 'exported' and 'virtual' a bit more. It also removes no-longer-needed functionality where resources copied their virtual or exported bits from the enclosing define or class. This is now obsolete because we don't evaluate virtual defined resources. The crux of this commit is that defined resources can stay exported even though they're evaluated, and that exported state won't inherit to contained resources such that those then don't get evaluated. Signed-off-by: Luke Kanies <luke@madstop.com>
* Fix #1682 - Resource titles are not flattened as they shouldBrice Figureau2009-02-111-0/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following manifest: $groups = ["foo", "bar"] $type_groups = ["baz", "quux"] $user_groups = [$groups, $type_groups] notify{ $user_groups: } which outputs: notice: foo notice: //Notify[foobar]/message: defined 'message' as 'foo' notice: baz notice: //Notify[bazquux]/message: defined 'message' as 'baz' is not equivalent to $user_groups = [ ["foo", "bar"], ["baz", "quux"] ] notify{ $user_groups: } which outputs: notice: foo notice: //Notify[foo]/message: defined 'message' as 'foo' notice: baz notice: //Notify[baz]/message: defined 'message' as 'baz' notice: bar notice: //Notify[bar]/message: defined 'message' as 'bar' notice: quux notice: //Notify[quux]/message: defined 'message' as 'quux' Obviously the second one manages to flatten the arrays and not the first one. This changeset adds flattening to the resource titles evaluations in order to be consitent in all cases. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #1922 - Functions squash all arguments into a single hashBrice Figureau2009-02-111-2/+2
| | | | | | | | Revert "Fix #1682 - ASTArray should flatten product of evaluation of its children" This reverts commit c7ccc4ba7c42d56595564491ae578a1604c628d1. Bug #1824 and #1922 proved the fix for #1682 and #1691 was wrong. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fixing the AST constant warnings, using a variable instead of a constantLuke Kanies2008-12-025-42/+42
| | | | Signed-off-by: Luke Kanies <luke@madstop.com>
* Fix #1759 - Comparison operator was using string comparison for numbersBrice Figureau2008-11-201-10/+50
| | | | Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Move function existance test to parser evaluationBrice Figureau2008-11-171-0/+77
| | | | | | | | The aim is to let --parseonly succeeds even if the function is not (yet) present. This is usefull in commit-hooks and for the inline documentation generation system. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #1682 - ASTArray should flatten product of evaluation of its childrenBrice Figureau2008-10-291-0/+66
| | | | | If the ASTArray contains children that evaluate to arrays themselves, they aren't flattened.
* Fixed #1104 - Classes and nodes should set $name variablesBrice Figureau2008-10-281-0/+13
| | | | Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #1202 - Collection attribute matching doesn't parse arraysBrice Figureau2008-10-081-0/+92
| | | | | | | | | | | | This patch allows to do this: User <| groups == leads |> @user { "foo": ensure => "present", groups => ["bar","baz","leads"] } Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #1109 - allow empty if or else branchesBrice Figureau2008-10-071-0/+20
| | | | | | | | | | | | This changesets allow empty if or else branches: if true { } else { } It works by emitting on the parser stack an AST node that doesn't do anything (a no-op). This allows the less intrusive code as no part of the if evaluation code has been touched.
* Rspec Tests for #381.Brice Figureau2008-10-052-0/+114
| | | | Moved part of the old resource reference tests to rspec.
* Add arithmetic operators to ASTBrice Figureau2008-09-302-0/+109
| | | | | This changeset adds +,-,/,*,<< and >> computation and AST parse nodes.
* Add not operator to ASTBrice Figureau2008-09-301-0/+30
|
* Add comparison operators (< > == != <= >=) to ASTBrice Figureau2008-09-301-0/+52
|
* Add boolean operators to ASTBrice Figureau2008-09-301-0/+53
|
* Add rspec unit test for the append operatorBrice Figureau2008-09-211-0/+47
| | | | Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fixes #1148 - replaces #!/usr/bin/ruby with #!/usr/bin/env ruby.Paul Lathrop2008-03-281-1/+1
|
* Fixing #1085, I think -- I was not returning a resourceLuke Kanies2008-02-251-1/+7
| | | | | | if the class had already been evaluated, but this was only being run into in corner cases -- mostly where one class included another class, I assume.
* converting parser ast node specs from setup/teardown to before/afterRick Bradley2008-02-181-83/+81
|
* converting parser ast host class specs from setup/teardown to before/afterRick Bradley2008-02-181-86/+84
|
* 'rake' within the spec dir works now, anyway, which isLuke Kanies2008-02-121-4/+4
| | | | a good start. Autotest still doesn't work, though.
* Moving the ast node tests to rspec (which I could haveLuke Kanies2008-02-122-0/+275
| | | | | | | *sworn* I did this weekend). In the process, I fixed a couple of bugs related to differentiating between nodes and classes, and then cleaned up quite a few error messages.
* Changing the name of the Compile class to Compiler,Luke Kanies2008-02-112-14/+14
| | | | | since it's stupid to have a class named after a verb.
* Fixed #1030 - class and definition evaluation has been significantlyLuke Kanies2008-02-111-0/+131
| | | | | | refactored, fixing this problem and making the whole interplay between the classes, definitions, and nodes, and the Compile class much cleaner.
* More AST refactoring -- each of the code wrapping classesLuke Kanies2008-02-081-1/+1
| | | | | | | | | | | just returns a resource from its evaluate() method, and all of the work is done in the evaluate_code method. This makes the code cleaner, because it means 1) evaluate() has the same prototype as all of the other AST classes, 2) evaluate() is no longer called indirectly through the Parser Resource class, and 3) the classes themselves are responsible for creating the resources, rather than it being done in the Compile class.
* Refactoring the AST classes just a bit. I realized thatLuke Kanies2008-02-081-3/+3
| | | | | | all of the evaluate() methods only ever accepted a scope, and sometimes one other option, so I switched them all to use named arguments instead of a hash.
* Adding this test stub that's been sittingLuke Kanies2007-10-181-0/+47
around in my repository for a while.