diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-05-13 02:14:35 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-05-13 02:14:35 +0000 |
commit | 0819e35be74bc997c3a953f05bab874b8d76429d (patch) | |
tree | a7abcf53ed750c8b530d7de88374a354f4b6bf2a /test | |
parent | 678e14286f441524955c76fcfca6abace7106774 (diff) | |
download | puppet-0819e35be74bc997c3a953f05bab874b8d76429d.tar.gz |
Adding some small changes towards fixing #140 and #83, but this work needs to take a back seat to object collection, so i will come back to it later.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1186 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-x | test/language/ast.rb | 53 | ||||
-rw-r--r-- | test/puppettest.rb | 27 |
2 files changed, 73 insertions, 7 deletions
diff --git a/test/language/ast.rb b/test/language/ast.rb index 781e9ddd0..b714fcdea 100755 --- a/test/language/ast.rb +++ b/test/language/ast.rb @@ -752,6 +752,59 @@ class TestAST < Test::Unit::TestCase "Could not find file %s" % file) end end + + # To fix #140. Currently non-functional. + def disabled_test_classreuse + children = [] + + # Create the parent class, with a definition in it. + children << classobj("parent", :code => AST::ASTArray.new( + :file => __FILE__, + :line => __LINE__, + :children => [ + compobj("foo", :args => AST::ASTArray.new( + :children => [nameobj("arg")] + ), + :code => AST::ASTArray.new( + :file => __FILE__, + :line => __LINE__, + :children => [fileobj("/$arg")] + ) + ), + objectdef("foo", "ptest", {"arg" => "parentfoo"}) + ] + )) + + # Create child class, also trying to use that definition + children << classobj("child1", :parentclass => nameobj("parent"), + :code => AST::ASTArray.new( + :file => __FILE__, + :line => __LINE__, + :children => [ + objectdef("foo", "ctest", {"arg" => "childfoo"}) + ] + ) + ) + + # Call the parent first + children << functionobj("include", "parent") + + # Then call the child, and make sure it can look up the definition + children << functionobj("include", "child1") + + top = nil + assert_nothing_raised("Could not create top object") { + top = AST::ASTArray.new( + :children => children + ) + } + + objects = nil + assert_nothing_raised("Could not evaluate") { + scope = Puppet::Parser::Scope.new() + objects = scope.evaluate(:ast => top) + } + end end # $Id$ diff --git a/test/puppettest.rb b/test/puppettest.rb index 375098d10..d0c7a5778 100644 --- a/test/puppettest.rb +++ b/test/puppettest.rb @@ -791,18 +791,31 @@ module ParserTesting } end - def fileobj(path, hash = {"owner" => "root"}) - assert_nothing_raised("Could not create file %s" % path) { + def objectdef(type, name, params) + assert_nothing_raised("Could not create %s %s" % [type, name]) { return AST::ObjectDef.new( - :file => tempfile(), - :line => rand(100), - :name => stringobj(path), - :type => nameobj("file"), - :params => objectinst(hash) + :file => __FILE__, + :line => __LINE__, + :name => stringobj(name), + :type => nameobj(type), + :params => objectinst(params) ) } end + def fileobj(path, hash = {"owner" => "root"}) + assert_nothing_raised("Could not create file %s" % path) { + return objectdef("file", path, hash) +# return AST::ObjectDef.new( +# :file => tempfile(), +# :line => rand(100), +# :name => stringobj(path), +# :type => nameobj("file"), +# :params => objectinst(hash) +# ) + } + end + def nameobj(name) assert_nothing_raised("Could not create name %s" % name) { return AST::Name.new( |