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 /spec/unit/parser | |
| 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 'spec/unit/parser')
| -rwxr-xr-x | spec/unit/parser/ast/casestatement.rb | 38 | ||||
| -rwxr-xr-x | spec/unit/parser/ast/leaf.rb | 4 | ||||
| -rwxr-xr-x | spec/unit/parser/ast/selector.rb | 16 |
3 files changed, 33 insertions, 25 deletions
diff --git a/spec/unit/parser/ast/casestatement.rb b/spec/unit/parser/ast/casestatement.rb index 657648e9d..c2e9a6929 100755 --- a/spec/unit/parser/ast/casestatement.rb +++ b/spec/unit/parser/ast/casestatement.rb @@ -57,13 +57,6 @@ describe Puppet::Parser::AST::CaseStatement do @casestmt.evaluate(@scope) end - it "should evaluate_match with sensitive parameter" do - Puppet.stubs(:[]).with(:casesensitive).returns(true) - @opval1.expects(:evaluate_match).with { |*arg| arg[2][:sensitive] == true } - - @casestmt.evaluate(@scope) - end - it "should return the first matching evaluated option" do @opval2.stubs(:evaluate_match).with { |*arg| arg[0] == "value" }.returns(true) @option2.stubs(:safeevaluate).with(@scope).returns(:result) @@ -130,4 +123,35 @@ describe Puppet::Parser::AST::CaseStatement do end end + + it "should match if any of the provided options evaluate as true" do + ast = nil + AST = Puppet::Parser::AST + + 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") + ast = AST::CaseStatement.new(:test => param, :options => options) + + tests.each do |should, values| + values.each do |value| + @scope = Puppet::Parser::Scope.new() + @scope.setvar("testparam", value) + result = ast.evaluate(@scope) + + result.should == should + end + end + end end diff --git a/spec/unit/parser/ast/leaf.rb b/spec/unit/parser/ast/leaf.rb index 2bb374702..d5534debb 100755 --- a/spec/unit/parser/ast/leaf.rb +++ b/spec/unit/parser/ast/leaf.rb @@ -32,7 +32,7 @@ describe Puppet::Parser::AST::Leaf do @leaf.stubs(:safeevaluate).with(@scope).returns(@value) @value.expects(:downcase).returns("value") - @leaf.evaluate_match("value", @scope, :sensitive => true) + @leaf.evaluate_match("value", @scope) end it "should match undef if value is an empty string" do @@ -45,7 +45,7 @@ describe Puppet::Parser::AST::Leaf do parameter = stub 'parameter' parameter.expects(:downcase).returns("value") - @leaf.evaluate_match(parameter, @scope, :sensitive => true) + @leaf.evaluate_match(parameter, @scope) end end diff --git a/spec/unit/parser/ast/selector.rb b/spec/unit/parser/ast/selector.rb index f9a1efe6c..23989b902 100755 --- a/spec/unit/parser/ast/selector.rb +++ b/spec/unit/parser/ast/selector.rb @@ -86,22 +86,6 @@ describe Puppet::Parser::AST::Selector do @selector.evaluate(@scope) end - it "should transmit the sensitive parameter to evaluate_match" do - Puppet.stubs(:[]).with(:casesensitive).returns(:sensitive) - @param1.expects(:evaluate_match).with { |*arg| arg[2][:sensitive] == :sensitive } - - @selector.evaluate(@scope) - end - - it "should transmit the AST file and line to evaluate_match" do - @selector.file = :file - @selector.line = :line - @param1.expects(:evaluate_match).with { |*arg| arg[2][:file] == :file and arg[2][:line] == :line } - - @selector.evaluate(@scope) - end - - it "should evaluate the matching param" do @param1.stubs(:evaluate_match).with { |*arg| arg[0] == "value" and arg[1] == @scope }.returns(true) |
