diff options
author | Luke Kanies <luke@puppetlabs.com> | 2010-04-09 16:02:32 -0700 |
---|---|---|
committer | Luke Kanies <luke@puppetlabs.com> | 2010-04-09 16:02:32 -0700 |
commit | b643413da520fabb7ee81e8c710e30f43bc1475b (patch) | |
tree | 747082b0577b566bbd2bb576d539cb7efebdc2c4 /test | |
parent | fe140a283fc51216a460be24c19641e26724c92c (diff) | |
download | puppet-b643413da520fabb7ee81e8c710e30f43bc1475b.tar.gz puppet-b643413da520fabb7ee81e8c710e30f43bc1475b.tar.xz puppet-b643413da520fabb7ee81e8c710e30f43bc1475b.zip |
Removing any mentions of :casesensitive setting
It is a setting that was added years ago as a backward
compatibility option and even if it still works, which
is questionable, it has no purpose any longer.
It just complicated the code and didn't do much, so it's gone
now.
Also simplified the interface of Leaf#evaluate_match, since it
was now using none of the passed-in options.
Finally, removed/migrated the last of the Selector/CaseStatement
test/unit tests.
Signed-off-by: Luke Kanies <luke@puppetlabs.com>
Diffstat (limited to 'test')
-rwxr-xr-x | test/language/ast/casestatement.rb | 103 | ||||
-rwxr-xr-x | test/language/ast/selector.rb | 61 |
2 files changed, 0 insertions, 164 deletions
diff --git a/test/language/ast/casestatement.rb b/test/language/ast/casestatement.rb deleted file mode 100755 index 2711455f2..000000000 --- a/test/language/ast/casestatement.rb +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/env ruby -# -# Created by Luke A. Kanies on 2006-12-22. -# Copyright (c) 2006. All rights reserved. - -require File.dirname(__FILE__) + '/../../lib/puppettest' - -require 'puppettest' -require 'puppettest/parsertesting' - -class TestCaseStatement < Test::Unit::TestCase - include PuppetTest - include PuppetTest::ParserTesting - AST = Puppet::Parser::AST - - class ActiveAST < FakeAST - def self.clear - $evaluated = [] - end - def evaluate - $evaluated ||= [] - $evaluated << @evaluate - end - end - - def test_evaluate - ast = nil - scope = mkscope - param = nameobj("MyParam") - - hash = { - "myparam" => ActiveAST.new("lower"), - "MyParam" => ActiveAST.new("upper"), - true => ActiveAST.new(true) - } - options = ["myparam", "MyParam"].collect do |p| - AST::CaseOpt.new(:value => FakeAST.new(p), :statements => hash[p]) - end - assert_nothing_raised do - ast = AST::CaseStatement.new(:test => param, :options => options) - end - - # Start out case-sensitive - Puppet[:casesensitive] = true - - result = nil - assert_nothing_raised do - result = ast.evaluate scope - end - assert(result, "did not get valid result") - assert_equal(["upper"], $evaluated, "Did not match case-sensitively") - assert(! hash["myparam"].evaluated?, "lower value was evaluated even though it did not match") - - # Now try it case-insensitive - Puppet[:casesensitive] = false - $evaluated.clear - hash["MyParam"].reset - assert_nothing_raised do - result = ast.evaluate scope - end - assert(result, "did not get valid result") - 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) - end - - assert_equal(should, result, "Got incorrect result for %s" % value) - end - end - end -end - diff --git a/test/language/ast/selector.rb b/test/language/ast/selector.rb deleted file mode 100755 index d2b1622d2..000000000 --- a/test/language/ast/selector.rb +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env ruby -# -# Created by Luke A. Kanies on 2006-12-22. -# Copyright (c) 2006. All rights reserved. - -require File.dirname(__FILE__) + '/../../lib/puppettest' - -require 'puppettest' -require 'puppettest/parsertesting' - -class TestSelector < Test::Unit::TestCase - include PuppetTest - include PuppetTest::ParserTesting - AST = Puppet::Parser::AST - - def test_evaluate - scope = mkscope - upperparam = nameobj("MYPARAM") - lowerparam = nameobj("myparam") - - should = {"MYPARAM" => "upper", "myparam" => "lower"} - - maker = Proc.new do - { - :default => AST::ResourceParam.new(:param => AST::Default.new(:value => "default"), :value => FakeAST.new("default")), - :lower => AST::ResourceParam.new(:param => FakeAST.new("myparam"), :value => FakeAST.new("lower")), - :upper => AST::ResourceParam.new(:param => FakeAST.new("MYPARAM"), :value => FakeAST.new("upper")), - } - - end - - # Start out case-sensitive - Puppet[:casesensitive] = true - - %w{MYPARAM myparam}.each do |str| - param = nameobj(str) - params = maker.call() - sel = AST::Selector.new(:param => param, :values => params.values) - result = nil - assert_nothing_raised { result = sel.evaluate(scope) } - assert_equal(should[str], result, "did not case-sensitively match %s" % str) - end - - # then insensitive - Puppet[:casesensitive] = false - - %w{MYPARAM myparam}.each do |str| - param = nameobj(str) - params = maker.call() - - # Delete the upper value, since we don't want it to match - # and it introduces a hash-ordering bug in testing. - params.delete(:upper) - sel = AST::Selector.new(:param => param, :values => params.values) - result = nil - assert_nothing_raised { result = sel.evaluate(scope) } - assert_equal("lower", result, "did not case-insensitively match %s" % str) - end - end -end - |