diff options
| author | Luke Kanies <luke@madstop.com> | 2008-02-08 14:25:52 -0600 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2008-02-08 14:25:52 -0600 |
| commit | 5a0e34b4f8da22e1830ec7d0a730c3686665bceb (patch) | |
| tree | d8635f754c2a0fee69e103cf6d85792ff4e736a1 /test/language/ast | |
| parent | 82720d5327b30839a29035ee0b498b940ffc7a5a (diff) | |
| download | puppet-5a0e34b4f8da22e1830ec7d0a730c3686665bceb.tar.gz puppet-5a0e34b4f8da22e1830ec7d0a730c3686665bceb.tar.xz puppet-5a0e34b4f8da22e1830ec7d0a730c3686665bceb.zip | |
Refactoring the AST classes just a bit. I realized that
all of the evaluate() methods only ever accepted a scope,
and sometimes one other option, so I switched them all to
use named arguments instead of a hash.
Diffstat (limited to 'test/language/ast')
| -rwxr-xr-x | test/language/ast/casestatement.rb | 6 | ||||
| -rwxr-xr-x | test/language/ast/definition.rb | 8 | ||||
| -rwxr-xr-x | test/language/ast/hostclass.rb | 14 | ||||
| -rwxr-xr-x | test/language/ast/resource.rb | 10 | ||||
| -rwxr-xr-x | test/language/ast/resource_reference.rb | 22 | ||||
| -rwxr-xr-x | test/language/ast/selector.rb | 4 | ||||
| -rwxr-xr-x | test/language/ast/variable.rb | 4 |
7 files changed, 34 insertions, 34 deletions
diff --git a/test/language/ast/casestatement.rb b/test/language/ast/casestatement.rb index 0a744b686..d95d788d9 100755 --- a/test/language/ast/casestatement.rb +++ b/test/language/ast/casestatement.rb @@ -45,7 +45,7 @@ class TestCaseStatement < Test::Unit::TestCase result = nil assert_nothing_raised do - result = ast.evaluate :scope => scope + result = ast.evaluate scope end assert(result, "did not get valid result") assert_equal(["upper"], $evaluated, "Did not match case-sensitively") @@ -56,7 +56,7 @@ class TestCaseStatement < Test::Unit::TestCase $evaluated.clear hash["MyParam"].reset assert_nothing_raised do - result = ast.evaluate :scope => scope + result = ast.evaluate scope end assert(result, "did not get valid result") assert_equal(["lower"], result, "Did not match case-insensitively") @@ -92,7 +92,7 @@ class TestCaseStatement < Test::Unit::TestCase scope = mkscope scope.setvar("testparam", value) assert_nothing_raised do - result = ast.evaluate(:scope => scope) + result = ast.evaluate(scope) end assert_equal(should, result, "Got incorrect result for %s" % value) diff --git a/test/language/ast/definition.rb b/test/language/ast/definition.rb index 2a71aaa45..5f415eb41 100755 --- a/test/language/ast/definition.rb +++ b/test/language/ast/definition.rb @@ -63,7 +63,7 @@ class TestASTDefinition < Test::Unit::TestCase resource.stubs(:title) assert_nothing_raised do - klass.evaluate(:scope => scope, :resource => resource) + klass.evaluate(scope, resource) end firstobj = config.findresource("File[/tmp/first]") @@ -76,7 +76,7 @@ class TestASTDefinition < Test::Unit::TestCase # Make sure we can't evaluate it with the same args assert_raise(Puppet::ParseError) do - klass.evaluate(:scope => scope, :resource => resource) + klass.evaluate(scope, resource) end # Now create another with different args @@ -93,7 +93,7 @@ class TestASTDefinition < Test::Unit::TestCase resource2.send(:set_parameter, "owner", "daemon") assert_nothing_raised do - klass.evaluate(:scope => scope, :resource => resource2) + klass.evaluate(scope, resource2) end secondobj = config.findresource("File[/tmp/second]") @@ -136,7 +136,7 @@ class TestASTDefinition < Test::Unit::TestCase end assert_nothing_raised("Could not evaluate definition with %s" % hash.inspect) do - klass.evaluate(:scope => scope, :resource => resource) + klass.evaluate(scope, resource) end name = hash[:name] || hash[:title] diff --git a/test/language/ast/hostclass.rb b/test/language/ast/hostclass.rb index 80032f30c..abc5e05be 100755 --- a/test/language/ast/hostclass.rb +++ b/test/language/ast/hostclass.rb @@ -29,12 +29,12 @@ class TestASTHostClass < Test::Unit::TestCase resource = Puppet::Parser::Resource.new(:type => "class", :title => "first", :scope => scope) assert_nothing_raised do - klass.evaluate(:scope => scope, :resource => resource) + klass.evaluate(scope, resource) end # Then try it again assert_nothing_raised do - klass.evaluate(:scope => scope, :resource => resource) + klass.evaluate(scope, resource) end assert(scope.compile.class_scope(klass), "Class was not considered evaluated") @@ -70,11 +70,11 @@ class TestASTHostClass < Test::Unit::TestCase ) assert_nothing_raised do - newsub.evaluate(:scope => scope, :resource => resource) + newsub.evaluate(scope, resource) end assert_nothing_raised do - moresub.evaluate(:scope => scope, :resource => resource) + moresub.evaluate(scope, resource) end assert(scope.compile.class_scope(newbase), "Did not eval newbase") @@ -174,11 +174,11 @@ class TestASTHostClass < Test::Unit::TestCase base = parser.newclass "base" sub = parser.newclass "sub", :parent => "base" - base.expects(:safeevaluate).with do |args| + base.expects(:safeevaluate).with do |*args| assert(scope.compile.catalog.tags.include?("sub"), "Did not tag with sub class name before evaluating base class") - base.evaluate(args) + base.evaluate(*args) true end - sub.evaluate :scope => scope, :resource => scope.resource + sub.evaluate scope, scope.resource end end diff --git a/test/language/ast/resource.rb b/test/language/ast/resource.rb index c99d98eeb..ef7800066 100755 --- a/test/language/ast/resource.rb +++ b/test/language/ast/resource.rb @@ -36,24 +36,24 @@ class TestASTResource< Test::Unit::TestCase title = "title" # First try a qualified type - assert_equal("One::Two", newdef("two", title).evaluate(:scope => twoscope)[0].type, + assert_equal("One::Two", newdef("two", title).evaluate(twoscope)[0].type, "Defined type was not made fully qualified") # Then try a type that does not need to be qualified - assert_equal("One", newdef("one", title).evaluate(:scope => twoscope)[0].type, + assert_equal("One", newdef("one", title).evaluate(twoscope)[0].type, "Unqualified defined type was not handled correctly") # Then an unqualified type from within the one namespace - assert_equal("Three", newdef("three", title).evaluate(:scope => twoscope)[0].type, + assert_equal("Three", newdef("three", title).evaluate(twoscope)[0].type, "Defined type was not made fully qualified") # Then a builtin type - assert_equal("File", newdef("file", title).evaluate(:scope => twoscope)[0].type, + assert_equal("File", newdef("file", title).evaluate(twoscope)[0].type, "Builtin type was not handled correctly") # Now try a type that does not exist, which should throw an error. assert_raise(Puppet::ParseError, "Did not fail on a missing type in a resource reference") do - newdef("nosuchtype", title).evaluate(:scope => twoscope) + newdef("nosuchtype", title).evaluate(twoscope) end end end diff --git a/test/language/ast/resource_reference.rb b/test/language/ast/resource_reference.rb index c9fde078f..9de3391d9 100755 --- a/test/language/ast/resource_reference.rb +++ b/test/language/ast/resource_reference.rb @@ -31,7 +31,7 @@ class TestASTResourceReference < Test::Unit::TestCase evaled = nil assert_nothing_raised("Could not evaluate resource ref") do - evaled = ref.evaluate(:scope => @scope) + evaled = ref.evaluate(@scope) end assert_equal(type, evaled.type, "Type did not translate correctly") @@ -44,7 +44,7 @@ class TestASTResourceReference < Test::Unit::TestCase ref = newref("Class", "one") evaled = nil assert_nothing_raised("Could not evaluate resource ref") do - evaled = ref.evaluate(:scope => @scope) + evaled = ref.evaluate(@scope) end assert_equal("Class", evaled.type, "Did not set type to 'class'") @@ -61,24 +61,24 @@ class TestASTResourceReference < Test::Unit::TestCase title = "title" # First try a qualified type - assert_equal("One::Two", newref("two", title).evaluate(:scope => twoscope).type, + assert_equal("One::Two", newref("two", title).evaluate(twoscope).type, "Defined type was not made fully qualified") # Then try a type that does not need to be qualified - assert_equal("One", newref("one", title).evaluate(:scope => twoscope).type, + assert_equal("One", newref("one", title).evaluate(twoscope).type, "Unqualified defined type was not handled correctly") # Then an unqualified type from within the one namespace - assert_equal("Three", newref("three", title).evaluate(:scope => twoscope).type, + assert_equal("Three", newref("three", title).evaluate(twoscope).type, "Defined type was not made fully qualified") # Then a builtin type - assert_equal("File", newref("file", title).evaluate(:scope => twoscope).type, + assert_equal("File", newref("file", title).evaluate(twoscope).type, "Builtin type was not handled correctly") # Now try a type that does not exist, which should throw an error. assert_raise(Puppet::ParseError, "Did not fail on a missing type in a resource reference") do - newref("nosuchtype", title).evaluate(:scope => twoscope) + newref("nosuchtype", title).evaluate(twoscope) end # Now run the same tests, but with the classes @@ -86,20 +86,20 @@ class TestASTResourceReference < Test::Unit::TestCase @parser.newclass "one::five" # First try an unqualified type - assert_equal("four", newref("class", "four").evaluate(:scope => twoscope).title, + assert_equal("four", newref("class", "four").evaluate(twoscope).title, "Unqualified class was not found") # Then a qualified class - assert_equal("one::five", newref("class", "five").evaluate(:scope => twoscope).title, + assert_equal("one::five", newref("class", "five").evaluate(twoscope).title, "Class was not made fully qualified") # Then try a type that does not need to be qualified - assert_equal("four", newref("class", "four").evaluate(:scope => twoscope).title, + assert_equal("four", newref("class", "four").evaluate(twoscope).title, "Unqualified class was not handled correctly") # Now try a type that does not exist, which should throw an error. assert_raise(Puppet::ParseError, "Did not fail on a missing type in a resource reference") do - newref("class", "nosuchclass").evaluate(:scope => twoscope) + newref("class", "nosuchclass").evaluate(twoscope) end end end diff --git a/test/language/ast/selector.rb b/test/language/ast/selector.rb index 535fcbf70..6e923bdcb 100755 --- a/test/language/ast/selector.rb +++ b/test/language/ast/selector.rb @@ -37,7 +37,7 @@ class TestSelector < Test::Unit::TestCase params = maker.call() sel = AST::Selector.new(:param => param, :values => params.values) result = nil - assert_nothing_raised { result = sel.evaluate(:scope => scope) } + assert_nothing_raised { result = sel.evaluate(scope) } assert_equal(should[str], result, "did not case-sensitively match %s" % str) end @@ -53,7 +53,7 @@ class TestSelector < Test::Unit::TestCase params.delete(:upper) sel = AST::Selector.new(:param => param, :values => params.values) result = nil - assert_nothing_raised { result = sel.evaluate(:scope => scope) } + assert_nothing_raised { result = sel.evaluate(scope) } assert_equal("lower", result, "did not case-insensitively match %s" % str) end end diff --git a/test/language/ast/variable.rb b/test/language/ast/variable.rb index 09122ce16..bde397bb4 100755 --- a/test/language/ast/variable.rb +++ b/test/language/ast/variable.rb @@ -22,9 +22,9 @@ class TestVariable < Test::Unit::TestCase end def test_evaluate - assert_equal("", @var.evaluate(:scope => @scope), "did not return empty string on unset var") + assert_equal("", @var.evaluate(@scope), "did not return empty string on unset var") @scope.setvar(@name, "something") - assert_equal("something", @var.evaluate(:scope => @scope), "incorrect variable value") + assert_equal("something", @var.evaluate(@scope), "incorrect variable value") end end |
