diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-05-09 05:50:34 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-05-09 05:50:34 +0000 |
| commit | 513b87a86e9b77bb9f1b011aa55222ce9cfb3a8d (patch) | |
| tree | eee376e11f0d3ec84972548af2ab804c7c062bfe /test | |
| parent | fe16f83a1b56f5d8644ee08585cc3086d4acc2a0 (diff) | |
Preliminary commit of the first phase of the parser redesign. The biggest difference is that overrides should now work for definitions (although i do not yet have a test case -- i will add one on the next commit). The way this is implemented is by having scopes translate themselves at eval time, but in two phases -- the first phase does the overrides, and the second phase does the evaluation of definitions and classes.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1180 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
| -rwxr-xr-x | test/language/ast.rb | 28 | ||||
| -rwxr-xr-x | test/language/scope.rb | 28 |
2 files changed, 34 insertions, 22 deletions
diff --git a/test/language/ast.rb b/test/language/ast.rb index ac9b53dad..c3753a9e5 100755 --- a/test/language/ast.rb +++ b/test/language/ast.rb @@ -53,13 +53,20 @@ class TestAST < Test::Unit::TestCase } scope = nil + objects = nil assert_nothing_raised("Could not evaluate") { scope = Puppet::Parser::Scope.new() - objects = top.evaluate(:scope => scope) + objects = scope.evaluate(:ast => top) } + assert_instance_of(Puppet::TransBucket, objects) + assert_equal(1, scope.find_all { |child| - child.lookupobject(:name => "/parent", :type => "file") + if child.is_a? Puppet::Parser::Scope + child.lookupobject(:name => "/parent", :type => "file") + else + nil + end }.length, "Found incorrect number of '/parent' objects") assert_equal(classes.sort, scope.classlist.sort) @@ -127,7 +134,7 @@ class TestAST < Test::Unit::TestCase scope = nil assert_raise(Puppet::ParseError, "Invalid parent type was allowed") { scope = Puppet::Parser::Scope.new() - objects = top.evaluate(:scope => scope) + objects = scope.evaluate(:ast => top) } end @@ -417,13 +424,16 @@ class TestAST < Test::Unit::TestCase objects = scope.evaluate(:names => [name], :facts => {}, :ast => top) } assert(objects, "Could not retrieve short node definition") + assert_instance_of(Puppet::TransBucket, objects) # And now verify that we got both the top and node objects assert_nothing_raised("Could not find top-declared object") { assert_equal("/testing", objects[0].name) } - assert_nothing_raised("Could not find node-declared object") { + assert_nothing_raised("Could not find node-declared object %s" % + "/%s" % name + ) { assert_equal("/%s" % name, objects[1][0].name) } end @@ -454,19 +464,19 @@ class TestAST < Test::Unit::TestCase # Evaluate the parse tree scope = nil + objects = nil assert_nothing_raised("Could not evaluate node") { scope = Puppet::Parser::Scope.new() - top.evaluate(:scope => scope) + objects = scope.evaluate(:ast => top) } # Verify we get the right classlist back assert_equal(classes.sort, scope.classlist.sort) # Verify we can find the node via a search list - objects = nil - assert_nothing_raised("Could not retrieve objects") { - objects = scope.to_trans - } + #assert_nothing_raised("Could not retrieve objects") { + # objects = scope.to_trans + #} assert(objects, "Could not retrieve objects") assert_nothing_raised("Could not find top-declared object") { diff --git a/test/language/scope.rb b/test/language/scope.rb index ff108f63b..01e752d39 100755 --- a/test/language/scope.rb +++ b/test/language/scope.rb @@ -430,18 +430,17 @@ class TestScope < Test::Unit::TestCase scope = nil assert_nothing_raised("Could not evaluate") { scope = Puppet::Parser::Scope.new() - #scope.name = "topscope" - #scope.type = "topscope" objects = scope.evaluate(:ast => top) } assert_equal(1, objects.length, "Returned too many objects: %s" % objects.inspect) + assert_equal(1, objects[0].length, "Returned too many objects: %s" % objects[0].inspect) + assert_nothing_raised { file = objects[0][0] - assert_equal("bin", file["owner"], "Value did not override correctly") } end @@ -530,13 +529,9 @@ class TestScope < Test::Unit::TestCase :children => stats ) scope = Puppet::Parser::Scope.new() - assert_nothing_raised { - scope.evaluate(:ast => top) - } - trans = nil assert_nothing_raised { - trans = scope.to_trans + trans = scope.evaluate(:ast => top) } obj = trans.find do |obj| obj.is_a? Puppet::TransObject end @@ -604,12 +599,22 @@ class TestScope < Test::Unit::TestCase ] )) + children << Puppet::Parser::AST::Function.new( + :name => "include", + :ftype => :statement, + :arguments => AST::ASTArray.new( + :children => [nameobj("one"), nameobj("two")] + ) + ) + top = AST::ASTArray.new(:children => children) - top.evaluate(:scope => scope) + #assert_nothing_raised { + # scope.function_include(["one", "two"]) + #} assert_nothing_raised { - scope.function_include(["one", "two"]) + scope.evaluate(:ast => top) } @@ -659,7 +664,4 @@ class TestScope < Test::Unit::TestCase end - - def test_defineandinclude - end end |
