summaryrefslogtreecommitdiffstats
path: root/test/language
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-02-27 06:09:07 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-02-27 06:09:07 +0000
commitc5d8680ba55598491c5798c842e65e4a4df54484 (patch)
tree5ff89631c95de2d95c79f0fa15bc7ca0eb7e90b8 /test/language
parentee818a96233e62d9c37a117265c6d68f78095689 (diff)
downloadpuppet-c5d8680ba55598491c5798c842e65e4a4df54484.tar.gz
puppet-c5d8680ba55598491c5798c842e65e4a4df54484.tar.xz
puppet-c5d8680ba55598491c5798c842e65e4a4df54484.zip
Fixing scopes and AST so that definitions and classes are looked for in the scopes, instead of in a global list
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@950 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/language')
-rwxr-xr-xtest/language/ast.rb103
-rwxr-xr-xtest/language/scope.rb5
2 files changed, 107 insertions, 1 deletions
diff --git a/test/language/ast.rb b/test/language/ast.rb
index 0dfb0d56c..c4fe67975 100755
--- a/test/language/ast.rb
+++ b/test/language/ast.rb
@@ -413,4 +413,107 @@ class TestAST < Test::Unit::TestCase
}
}
end
+
+ def test_typechecking
+ object = nil
+ children = []
+ type = "deftype"
+ assert_nothing_raised("Could not add AST nodes for calling") {
+ object = AST::ObjectDef.new(
+ :type => nameobj(type),
+ :name => nameobj("yayness"),
+ :params => astarray()
+ )
+ }
+
+ assert_nothing_raised("Typecheck failed") {
+ object.typecheck(type)
+ }
+
+ # Add a scope, which makes it think it's evaluating
+ assert_nothing_raised {
+ scope = Puppet::Parser::Scope.new()
+ object.scope = scope
+ }
+
+ # Verify an error is thrown when it can't find the type
+ assert_raise(Puppet::ParseError) {
+ object.typecheck(type)
+ }
+
+ # Create child class one
+ children << classobj(type)
+ children << object
+
+ top = nil
+ assert_nothing_raised("Could not create top object") {
+ top = AST::ASTArray.new(
+ :children => children
+ )
+ }
+
+ scope = nil
+ assert_nothing_raised("Could not evaluate") {
+ scope = Puppet::Parser::Scope.new()
+ objects = top.evaluate(scope)
+ }
+ end
+
+ def disabled_test_paramcheck
+ object = nil
+ children = []
+ type = "deftype"
+ params = %w{param1 param2}
+
+ comp = compobj(type, {
+ :args => astarray(
+ argobj("param1", "yay"),
+ argobj("param2", "rah")
+ ),
+ :code => AST::ASTArray.new(
+ :children => [
+ varobj("%svar" % name, "%svalue" % name),
+ fileobj("/%s" % name)
+ ]
+ )
+ })
+ assert_nothing_raised("Could not add AST nodes for calling") {
+ object = AST::ObjectDef.new(
+ :type => nameobj(type),
+ :name => nameobj("yayness"),
+ :params => astarray(
+ astarray(stringobj("param1"), stringobj("value1")),
+ astarray(stringobj("param2"), stringobj("value2"))
+ )
+ )
+ }
+
+ # Add a scope, which makes it think it's evaluating
+ assert_nothing_raised {
+ scope = Puppet::Parser::Scope.new()
+ object.scope = scope
+ }
+
+ # Verify an error is thrown when it can't find the type
+ assert_raise(Puppet::ParseError) {
+ object.paramcheck(false, comp)
+ }
+
+ # Create child class one
+ children << classobj(type)
+ children << object
+
+ top = nil
+ assert_nothing_raised("Could not create top object") {
+ top = AST::ASTArray.new(
+ :children => children
+ )
+ }
+
+ scope = nil
+ assert_nothing_raised("Could not evaluate") {
+ scope = Puppet::Parser::Scope.new()
+ objects = top.evaluate(scope)
+ }
+ end
end
diff --git a/test/language/scope.rb b/test/language/scope.rb
index 707372d1a..20c07d742 100755
--- a/test/language/scope.rb
+++ b/test/language/scope.rb
@@ -305,7 +305,7 @@ class TestScope < Test::Unit::TestCase
# Verify that two statements about a file within the same scope tree
# will cause a conflict.
- def test_znoconflicts
+ def test_noconflicts
filename = tempfile()
children = []
@@ -411,4 +411,7 @@ class TestScope < Test::Unit::TestCase
assert_equal("bin", file["owner"], "Value did not override correctly")
}
end
+
+ def test_classscopes
+ end
end