summaryrefslogtreecommitdiffstats
path: root/spec/integration/parser
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2011-05-12 15:40:08 -0700
committerNick Lewis <nick@puppetlabs.com>2011-05-17 14:54:43 -0700
commit3ac7aede7233e0554077f7abbf6e561960a05e4d (patch)
tree6d60a694bfe85a01a53b1314d4f6c6d9363f99e8 /spec/integration/parser
parent99d437d2bbc2339f092304715ec562fbbcb0a50c (diff)
downloadpuppet-3ac7aede7233e0554077f7abbf6e561960a05e4d.tar.gz
puppet-3ac7aede7233e0554077f7abbf6e561960a05e4d.tar.xz
puppet-3ac7aede7233e0554077f7abbf6e561960a05e4d.zip
(#7523) Refactor the grammar to reduce duplication
This commit unifies some paths in the grammar, which had previously been duplicated to avoid shift/reduce conflicts. Merging these paths together and separating only the conflicting structures leads to a cleaner grammar, with fewer holes. Several bugs are fixed as a result: (#3129) Nested class names beginning with numbers work correctly (#5268) Hyphens in class names work correctly (#5817) Hashes and arrays can now be passed to functions (hashes require parentheses) Additionally, expressions are now legal in most places where they would make sense, when previously only bare rvalues were allowed. Paired-With: Markus Roberts Reviewed-By: Matt Robinson
Diffstat (limited to 'spec/integration/parser')
-rwxr-xr-xspec/integration/parser/parser_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/integration/parser/parser_spec.rb b/spec/integration/parser/parser_spec.rb
index 65c9ee302..b55aa04ce 100755
--- a/spec/integration/parser/parser_spec.rb
+++ b/spec/integration/parser/parser_spec.rb
@@ -117,5 +117,36 @@ describe Puppet::Parser::Parser do
$out = $hash['a']['b']['c']
}.should parse_with { |v| v.value.is_a?(Puppet::Parser::AST::ASTHash) }
end
+
+ it "should fail if asked to parse '$foo::::bar'" do
+ expect { @parser.parse("$foo::::bar") }.should raise_error(Puppet::ParseError, /Syntax error at ':'/)
+ end
+
+ describe "function calls" do
+ it "should be able to pass an array to a function" do
+ "my_function([1,2,3])".should parse_with { |fun|
+ fun.is_a?(Puppet::Parser::AST::Function) &&
+ fun.arguments.first.evaluate(stub 'scope') == ['1','2','3']
+ }
+ end
+
+ it "should be able to pass a hash to a function" do
+ "my_function({foo => bar})".should parse_with { |fun|
+ fun.is_a?(Puppet::Parser::AST::Function) &&
+ fun.arguments.first.evaluate(stub 'scope') == {'foo' => 'bar'}
+ }
+ end
+ end
+
+ describe "collections" do
+ it "should find resources according to an expression" do
+ %q{
+ File <| mode == 0700 + 0050 + 0050 |>
+ }.should parse_with { |coll|
+ coll.is_a?(Puppet::Parser::AST::Collection) &&
+ coll.query.evaluate(stub 'scope').first == "param_values.value = '528' and param_names.name = 'mode'"
+ }
+ end
+ end
end
end