diff options
author | Paul Berry <paul@puppetlabs.com> | 2010-08-25 11:29:23 -0700 |
---|---|---|
committer | Paul Berry <paul@puppetlabs.com> | 2010-08-27 10:29:23 -0700 |
commit | df088c9ba16dce50c17a79920c1ac186db67b9e9 (patch) | |
tree | 9759f8d51b94508b942c1c434df7e8246031857b /test/lib | |
parent | 16f701edd89a320ad73b5468d883dfb017fe6e96 (diff) | |
download | puppet-df088c9ba16dce50c17a79920c1ac186db67b9e9.tar.gz puppet-df088c9ba16dce50c17a79920c1ac186db67b9e9.tar.xz puppet-df088c9ba16dce50c17a79920c1ac186db67b9e9.zip |
[4638] Cleanup of plurals and inheritance relationships in AST
Changed the grammar so that the following "plural" constructs always
parse as an ASTArray:
- funcvalues
- rvalues
- resourceinstances
- anyparams
- params
- caseopts
- casevalues
And the following "singluar" construct never parses as an ASTArray:
- statement
The previous behavior was for these constructs to parse as a scalar
when they represented a single item and an ASTArray when they
contained zero or multiple items. ("Statement" could sometimes
represent a single item because a single resource declaration could
represent multiple resources). This complicated other grammar rules
and caused ambiguous handling of nested arrays.
Also made these changes to the AST class hierarchy:
- ResourceInstance no longer derives from ASTArray. This relationship
was not meaningful because a ResourceInstance is a (title,
parameters) pair, not an array, and it produced complications when
we wanted to represent an array of ResourceInstance objects.
- Resource no longer derives from ResourceReference. No significant
functionality was being inherited and the relationship doesn't make
sense in an AST context.
- ResourceOverride no longer derives from Resource. No significant
functionality was being inherited and the relationship doesn't make
sense in an AST context.
- Resource can now represent a compound resource instance such as
"notify { foo: ; bar: }". This saves the parser from having to
use represent a statement as an array of objects.
- ASTArray's evaluate method never flattens out arrays of arrays.
Diffstat (limited to 'test/lib')
-rw-r--r-- | test/lib/puppettest/parsertesting.rb | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/test/lib/puppettest/parsertesting.rb b/test/lib/puppettest/parsertesting.rb index bd04c1ec5..411bad37a 100644 --- a/test/lib/puppettest/parsertesting.rb +++ b/test/lib/puppettest/parsertesting.rb @@ -94,16 +94,15 @@ module PuppetTest::ParserTesting def resourcedef(type, title, params) title = stringobj(title) unless title.is_a?(AST) + instance = AST::ResourceInstance.new(:title => title, :parameters => resourceparams(params)) assert_nothing_raised("Could not create #{type} #{title}") { return AST::Resource.new( :file => __FILE__, :line => __LINE__, - :title => title, :type => type, - - :parameters => resourceinst(params) + :instances => AST::ASTArray.new(:children => [instance]) ) } end @@ -122,9 +121,7 @@ module PuppetTest::ParserTesting :file => __FILE__, :line => __LINE__, :object => resourceref(type, title), - - :type => type, - :parameters => resourceinst(params) + :parameters => resourceparams(params) ) } end @@ -197,13 +194,13 @@ module PuppetTest::ParserTesting } end - def resourceinst(hash) + def resourceparams(hash) assert_nothing_raised("Could not create resource instance") { params = hash.collect { |param, value| resourceparam(param, value) } - return AST::ResourceInstance.new( + return AST::ASTArray.new( :file => tempfile, |