summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-03-03 18:23:53 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-03-03 18:23:53 +0000
commitaae9b2aa90c2f1e12baeebe530a0cd8a69fac9c2 (patch)
tree22430454ec25742a384e11ac91f829598a8aea42 /test
parent451ba6d069cb253f901541f420e51c0b184d8d8c (diff)
downloadpuppet-aae9b2aa90c2f1e12baeebe530a0cd8a69fac9c2.tar.gz
puppet-aae9b2aa90c2f1e12baeebe530a0cd8a69fac9c2.tar.xz
puppet-aae9b2aa90c2f1e12baeebe530a0cd8a69fac9c2.zip
Definitions now always create their own context, which means that they cannot override elements in the containing scopes.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@972 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-xtest/language/scope.rb49
-rw-r--r--test/puppettest.rb27
2 files changed, 63 insertions, 13 deletions
diff --git a/test/language/scope.rb b/test/language/scope.rb
index 2921afb42..a18b75bff 100755
--- a/test/language/scope.rb
+++ b/test/language/scope.rb
@@ -464,4 +464,53 @@ class TestScope < Test::Unit::TestCase
objects = top.evaluate(:scope => scope)
}
end
+
+ # Verify that definitions have a different context than classes.
+ def test_newsubcontext
+ filename = tempfile()
+ children = []
+
+ # Create a component
+ children << compobj("comp", :code => AST::ASTArray.new(
+ :children => [
+ fileobj(filename, "owner" => "root" )
+ ]
+ ))
+
+ # Now create a class that modifies the same file and also
+ # calls the component
+ children << classobj("klass", :code => AST::ASTArray.new(
+ :children => [
+ fileobj(filename, "owner" => "bin" ),
+ AST::ObjectDef.new(
+ :type => nameobj("comp"),
+ :params => astarray()
+ )
+ ]
+ ))
+
+ # Now call the class
+ children << AST::ObjectDef.new(
+ :type => nameobj("klass"),
+ :params => astarray()
+ )
+
+ top = nil
+ assert_nothing_raised("Could not create top object") {
+ top = AST::ASTArray.new(
+ :children => children
+ )
+ }
+
+ trans = nil
+ scope = nil
+ #assert_nothing_raised {
+ assert_raise(Puppet::ParseError, "A conflict was allowed") {
+ scope = Puppet::Parser::Scope.new()
+ trans = scope.evaluate(:ast => top)
+ }
+ # scope = Puppet::Parser::Scope.new()
+ # trans = scope.evaluate(:ast => top)
+ #}
+ end
end
diff --git a/test/puppettest.rb b/test/puppettest.rb
index 54dfc1f17..a16f4d80b 100644
--- a/test/puppettest.rb
+++ b/test/puppettest.rb
@@ -708,19 +708,15 @@ module ParserTesting
end
def classobj(name, args = {})
- unless args.include?(:name)
- args[:type] = nameobj(name)
- end
- unless args.include?(:code)
- args[:code] = AST::ASTArray.new(
- :file => tempfile(),
- :line => rand(100),
- :children => [
- varobj("%svar" % name, "%svalue" % name),
- fileobj("/%s" % name)
- ]
- )
- end
+ args[:type] ||= nameobj(name)
+ args[:code] ||= AST::ASTArray.new(
+ :file => tempfile(),
+ :line => rand(100),
+ :children => [
+ varobj("%svar" % name, "%svalue" % name),
+ fileobj("/%s" % name)
+ ]
+ )
assert_nothing_raised("Could not create class %s" % name) {
return AST::ClassDef.new(args)
}
@@ -730,6 +726,11 @@ module ParserTesting
args[:file] ||= tempfile()
args[:line] ||= rand(100)
args[:type] ||= nameobj(name)
+ args[:args] ||= AST::ASTArray.new(
+ :file => tempfile(),
+ :line => rand(100),
+ :children => []
+ )
args[:code] ||= AST::ASTArray.new(
:file => tempfile(),
:line => rand(100),