summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-02-27 21:31:02 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-02-27 21:31:02 +0000
commit87f100aa6ffc3087028a956ab73e19daf8f27f52 (patch)
tree9241a749173e1b437bf1c3b8bea51488e7f7dcfe /test
parenta3f36748528ea760b5965f972941c6022d0449e9 (diff)
downloadpuppet-87f100aa6ffc3087028a956ab73e19daf8f27f52.tar.gz
puppet-87f100aa6ffc3087028a956ab73e19daf8f27f52.tar.xz
puppet-87f100aa6ffc3087028a956ab73e19daf8f27f52.zip
Applying patch by DavidS from #522, along with test code and a small bit of code cleanup.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2231 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-xtest/language/ast/casestatement.rb39
1 files changed, 38 insertions, 1 deletions
diff --git a/test/language/ast/casestatement.rb b/test/language/ast/casestatement.rb
index 493474909..036216757 100755
--- a/test/language/ast/casestatement.rb
+++ b/test/language/ast/casestatement.rb
@@ -62,6 +62,43 @@ class TestCaseStatement < Test::Unit::TestCase
assert_equal(["lower"], result, "Did not match case-insensitively")
assert(! hash["MyParam"].evaluated?, "upper value was evaluated even though it did not match")
end
+
+ # #522 - test that case statements with multiple values work as
+ # expected, where any true value suffices.
+ def test_multiple_values
+ ast = nil
+
+ tests = {
+ "one" => %w{a b c},
+ "two" => %w{e f g}
+ }
+ options = tests.collect do |result, values|
+ values = values.collect { |v| AST::Leaf.new :value => v }
+ AST::CaseOpt.new(:value => AST::ASTArray.new(:children => values),
+ :statements => AST::Leaf.new(:value => result))
+ end
+ options << AST::CaseOpt.new(:value => AST::Default.new(:value => "default"),
+ :statements => AST::Leaf.new(:value => "default"))
+
+ ast = nil
+ param = AST::Variable.new(:value => "testparam")
+ assert_nothing_raised do
+ ast = AST::CaseStatement.new(:test => param, :options => options)
+ end
+ result = nil
+ tests.each do |should, values|
+ values.each do |value|
+ result = nil
+ scope = mkscope
+ scope.setvar("testparam", value)
+ assert_nothing_raised do
+ result = ast.evaluate(:scope => scope)
+ end
+
+ assert_equal(should, result, "Got incorrect result for %s" % value)
+ end
+ end
+ end
end
-# $Id$ \ No newline at end of file
+# $Id$