summaryrefslogtreecommitdiffstats
path: root/test/language
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-05-12 22:22:45 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-05-12 22:22:45 +0000
commit678e14286f441524955c76fcfca6abace7106774 (patch)
tree06d37afc1841edcefeae23d5ad9f245df5ebdfa8 /test/language
parent578cf7e575c4bb3a297506c75035aed2b2ef607b (diff)
downloadpuppet-678e14286f441524955c76fcfca6abace7106774.tar.gz
puppet-678e14286f441524955c76fcfca6abace7106774.tar.xz
puppet-678e14286f441524955c76fcfca6abace7106774.zip
Fixing #141. It was a problem related to the recent parser changes I made.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1185 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/language')
-rwxr-xr-xtest/language/ast.rb75
-rwxr-xr-xtest/language/functions.rb73
-rwxr-xr-xtest/language/snippets.rb8
3 files changed, 113 insertions, 43 deletions
diff --git a/test/language/ast.rb b/test/language/ast.rb
index c3753a9e5..781e9ddd0 100755
--- a/test/language/ast.rb
+++ b/test/language/ast.rb
@@ -712,57 +712,46 @@ class TestAST < Test::Unit::TestCase
assert(scope.classlist.include?("node"), "Node's name did not get set")
end
- def test_functions
- assert_raise(Puppet::ParseError) do
- Puppet::Parser::AST::Function.new(
- :name => "fakefunction",
- :arguments => AST::ASTArray.new(
- :children => [nameobj("avalue")]
- )
- )
- end
-
- assert_nothing_raised do
- Puppet::Parser::Functions.newfunction(:fakefunction, :rvalue) do |input|
- return "output %s" % input[0]
- end
- end
+ # Make sure that deep class parentage works
+ def test_classparentage
+ children = []
+ files = []
+ base = classobj("base")
+ files << "/base"
- func = nil
- assert_nothing_raised do
- func = Puppet::Parser::AST::Function.new(
- :name => "fakefunction",
- :ftype => :rvalue,
- :arguments => AST::ASTArray.new(
- :children => [nameobj("avalue")]
- )
- )
- end
+ children << base
- scope = Puppet::Parser::Scope.new()
- val = nil
- assert_nothing_raised do
- val = func.evaluate(:scope => scope)
- end
+ parent = "base"
+ 5.times { |i|
+ name = "child%s" % i
+ files << "/%s" % name
+ children << classobj(name, :parentclass => nameobj(parent))
- assert_equal("output avalue", val)
- end
+ parent = name
+ }
- def test_taggedfunction
- scope = Puppet::Parser::Scope.new()
+ children << functionobj("include", parent)
- tag = "yayness"
- scope.setclass(tag.object_id, tag)
+ top = nil
+ assert_nothing_raised("Could not create top object") {
+ top = AST::ASTArray.new(
+ :children => children
+ )
+ }
- {"yayness" => true, "booness" => false}.each do |tag, retval|
- func = taggedobj(tag, :rvalue)
+ objects = nil
+ assert_nothing_raised("Could not evaluate") {
+ scope = Puppet::Parser::Scope.new()
+ objects = scope.evaluate(:ast => top)
+ }
- val = nil
- assert_nothing_raised do
- val = func.evaluate(:scope => scope)
- end
+ objects = objects.flatten
- assert_equal(retval, val, "'tagged' returned %s for %s" % [val, tag])
+ files.each do |file|
+ assert(objects.find { |o| o.name == file },
+ "Could not find file %s" % file)
end
end
end
+
+# $Id$
diff --git a/test/language/functions.rb b/test/language/functions.rb
new file mode 100755
index 000000000..e39e23df7
--- /dev/null
+++ b/test/language/functions.rb
@@ -0,0 +1,73 @@
+#!/usr/bin/ruby
+
+if __FILE__ == $0
+ $:.unshift '../../lib'
+ $:.unshift '..'
+ $puppetbase = "../.."
+end
+
+require 'puppet'
+require 'puppet/parser/interpreter'
+require 'puppet/parser/parser'
+require 'puppet/client'
+require 'test/unit'
+require 'puppettest'
+
+class TestLangFunctions < Test::Unit::TestCase
+ include ParserTesting
+ def test_functions
+ assert_raise(Puppet::ParseError) do
+ Puppet::Parser::AST::Function.new(
+ :name => "fakefunction",
+ :arguments => AST::ASTArray.new(
+ :children => [nameobj("avalue")]
+ )
+ )
+ end
+
+ assert_nothing_raised do
+ Puppet::Parser::Functions.newfunction(:fakefunction, :rvalue) do |input|
+ return "output %s" % input[0]
+ end
+ end
+
+ func = nil
+ assert_nothing_raised do
+ func = Puppet::Parser::AST::Function.new(
+ :name => "fakefunction",
+ :ftype => :rvalue,
+ :arguments => AST::ASTArray.new(
+ :children => [nameobj("avalue")]
+ )
+ )
+ end
+
+ scope = Puppet::Parser::Scope.new()
+ val = nil
+ assert_nothing_raised do
+ val = func.evaluate(:scope => scope)
+ end
+
+ assert_equal("output avalue", val)
+ end
+
+ def test_taggedfunction
+ scope = Puppet::Parser::Scope.new()
+
+ tag = "yayness"
+ scope.setclass(tag.object_id, tag)
+
+ {"yayness" => true, "booness" => false}.each do |tag, retval|
+ func = taggedobj(tag, :rvalue)
+
+ val = nil
+ assert_nothing_raised do
+ val = func.evaluate(:scope => scope)
+ end
+
+ assert_equal(retval, val, "'tagged' returned %s for %s" % [val, tag])
+ end
+ end
+end
+
+# $Id$
diff --git a/test/language/snippets.rb b/test/language/snippets.rb
index 287bc615b..0ba2fb6ed 100755
--- a/test/language/snippets.rb
+++ b/test/language/snippets.rb
@@ -453,6 +453,14 @@ class TestSnippets < Test::Unit::TestCase
assert_equal(0755, filemode(file))
end
+ def snippet_deepclassheirarchy(trans)
+ 5.times { |i|
+ i += 1
+ file = "/tmp/deepclassheir%s" % i
+ assert(FileTest.exists?(file), "File %s does not exist" % file)
+ }
+ end
+
def snippet_emptyclass(trans)
# There's nothing to check other than that it works
end