diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-05-14 15:19:48 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-05-14 15:19:48 +0000 |
| commit | 27cabf25fc08ee77df08ec65a440f9d164b9215d (patch) | |
| tree | 558ae2a8d0709c75c53601afa1021125dc9d4950 /test | |
| parent | 613c413cd84a690f1fb0cb625380e430bc502c84 (diff) | |
Fixing a weird bug that occurred because I was changing @parentclass in the AST stuff the first time it was called, from a string to a the actual instance of the parent. This worked fine as long as the parentclass was only called when parsing was complete, such as during evaluation, but if anything resulted in it being called earlier (e.g., attempting to add to the class during parsing), then things behaved, um, badly. This commit fixes the method so that the variable is not modified; there is now @parentclass and @parentobj.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2511 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
| -rwxr-xr-x | test/language/interpreter.rb | 16 | ||||
| -rwxr-xr-x | test/language/parser.rb | 4 |
2 files changed, 11 insertions, 9 deletions
diff --git a/test/language/interpreter.rb b/test/language/interpreter.rb index 74c6e4642..7fe4eacac 100755 --- a/test/language/interpreter.rb +++ b/test/language/interpreter.rb @@ -379,14 +379,14 @@ class TestInterpreter < Test::Unit::TestCase # Make sure trying to get the parentclass throws an error assert_raise(Puppet::ParseError) do - interp.nodesearch_code("simplenode").parentclass + interp.nodesearch_code("simplenode").parentobj end # Now define the parent node interp.newnode(:foo) # And make sure we get things back correctly - assert_equal("foo", interp.nodesearch_code("simplenode").parentclass.classname) + assert_equal("foo", interp.nodesearch_code("simplenode").parentobj.classname) assert_nil(interp.nodesearch_code("simplenode").code) # Now make sure that trying to redefine it throws an error. @@ -402,7 +402,7 @@ class TestInterpreter < Test::Unit::TestCase names.each do |name| assert_equal(:yay, interp.nodesearch_code(name).code) - assert_equal("foo", interp.nodesearch_code(name).parentclass.name) + assert_equal("foo", interp.nodesearch_code(name).parentobj.name) # Now make sure that trying to redefine it throws an error. assert_raise(Puppet::ParseError) { interp.newnode(name, {}) @@ -655,9 +655,11 @@ class TestInterpreter < Test::Unit::TestCase interp.newclass("sub", :parent => "base1") } - # Make sure we get the right parent class, and make sure it's an object. - assert_equal(interp.findclass("", "base1"), + # Make sure we get the right parent class, and make sure it's not an object. + assert_equal("base1", interp.findclass("", "sub").parentclass) + assert_equal(interp.findclass("", "base1"), + interp.findclass("", "sub").parentobj) # Now make sure we get a failure if we try to conflict. assert_raise(Puppet::ParseError) { @@ -666,13 +668,13 @@ class TestInterpreter < Test::Unit::TestCase # Make sure that failure didn't screw us up in any way. assert_equal(interp.findclass("", "base1"), - interp.findclass("", "sub").parentclass) + interp.findclass("", "sub").parentobj) # But make sure we can create a class with a fq parent assert_nothing_raised { interp.newclass("another", :parent => "one::two::three") } assert_equal(interp.findclass("", "one::two::three"), - interp.findclass("", "another").parentclass) + interp.findclass("", "another").parentobj) end diff --git a/test/language/parser.rb b/test/language/parser.rb index a555c0082..ce54efc7e 100755 --- a/test/language/parser.rb +++ b/test/language/parser.rb @@ -397,7 +397,7 @@ file { "/tmp/yayness": } sub = interp.findclass("", "container::deep::sub") assert(sub, "Could not find sub") - assert_equal("base", sub.parentclass.classname) + assert_equal("base", sub.parentobj.classname) # Now try it with a parent class being a fq class assert_nothing_raised { @@ -405,7 +405,7 @@ file { "/tmp/yayness": } sub = interp.findclass("", "container::one") assert(sub, "Could not find one") - assert_equal("container::deep::sub", sub.parentclass.classname) + assert_equal("container::deep::sub", sub.parentobj.classname) # Finally, try including a qualified class assert_nothing_raised("Could not include fully qualified class") { |
