summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/parser/ast.rb6
-rw-r--r--lib/puppet/parser/ast/astarray.rb5
-rw-r--r--lib/puppet/parser/ast/caseopt.rb8
-rw-r--r--lib/puppet/parser/ast/casestatement.rb9
-rw-r--r--lib/puppet/parser/ast/collection.rb6
-rw-r--r--lib/puppet/parser/ast/collexpr.rb8
-rw-r--r--lib/puppet/parser/ast/definition.rb9
-rw-r--r--lib/puppet/parser/ast/else.rb5
-rw-r--r--lib/puppet/parser/ast/function.rb13
-rw-r--r--lib/puppet/parser/ast/hostclass.rb12
-rw-r--r--lib/puppet/parser/ast/ifstatement.rb9
-rw-r--r--lib/puppet/parser/ast/leaf.rb12
-rw-r--r--lib/puppet/parser/ast/node.rb16
-rw-r--r--lib/puppet/parser/ast/resource.rb8
-rw-r--r--lib/puppet/parser/ast/resource_defaults.rb6
-rw-r--r--lib/puppet/parser/ast/resource_override.rb8
-rw-r--r--lib/puppet/parser/ast/resource_reference.rb6
-rw-r--r--lib/puppet/parser/ast/resourceparam.rb6
-rw-r--r--lib/puppet/parser/ast/selector.rb11
-rw-r--r--lib/puppet/parser/ast/tag.rb6
-rw-r--r--lib/puppet/parser/ast/vardef.rb7
-rw-r--r--lib/puppet/parser/resource.rb2
-rwxr-xr-xspec/unit/parser/ast/definition.rb6
-rwxr-xr-xspec/unit/parser/resource.rb6
-rwxr-xr-xtest/language/ast.rb16
-rwxr-xr-xtest/language/ast/casestatement.rb6
-rwxr-xr-xtest/language/ast/definition.rb8
-rwxr-xr-xtest/language/ast/hostclass.rb14
-rwxr-xr-xtest/language/ast/resource.rb10
-rwxr-xr-xtest/language/ast/resource_reference.rb22
-rwxr-xr-xtest/language/ast/selector.rb4
-rwxr-xr-xtest/language/ast/variable.rb4
-rwxr-xr-xtest/language/functions.rb22
-rwxr-xr-xtest/language/parser.rb12
-rwxr-xr-xtest/language/resource.rb3
-rwxr-xr-xtest/language/scope.rb4
36 files changed, 136 insertions, 179 deletions
diff --git a/lib/puppet/parser/ast.rb b/lib/puppet/parser/ast.rb
index cac18fef4..c9bd7c9e8 100644
--- a/lib/puppet/parser/ast.rb
+++ b/lib/puppet/parser/ast.rb
@@ -27,7 +27,7 @@ class Puppet::Parser::AST
# should override this method.
# of the contained children and evaluates them in turn, returning a
# list of all of the collected values, rejecting nil values
- def evaluate(args)
+ def evaluate(*options)
raise Puppet::DevError, "Did not override #evaluate in %s" % self.class
end
@@ -47,11 +47,11 @@ class Puppet::Parser::AST
# correctly handles errors. It is critical to use this method because
# it can enable you to catch the error where it happens, rather than
# much higher up the stack.
- def safeevaluate(options)
+ def safeevaluate(*options)
# We duplicate code here, rather than using exceptwrap, because this
# is called so many times during parsing.
begin
- return self.evaluate(options)
+ return self.evaluate(*options)
rescue Puppet::Error => detail
raise adderrorcontext(detail)
rescue => detail
diff --git a/lib/puppet/parser/ast/astarray.rb b/lib/puppet/parser/ast/astarray.rb
index 5f1e838d0..b66fd6bba 100644
--- a/lib/puppet/parser/ast/astarray.rb
+++ b/lib/puppet/parser/ast/astarray.rb
@@ -15,8 +15,7 @@ class Puppet::Parser::AST
end
# Evaluate our children.
- def evaluate(hash)
- scope = hash[:scope]
+ def evaluate(scope)
rets = nil
# We basically always operate declaratively, and when we
# do we need to evaluate the settor-like statements first. This
@@ -51,7 +50,7 @@ class Puppet::Parser::AST
}
rets = [settors, others].flatten.collect { |child|
- child.safeevaluate(:scope => scope)
+ child.safeevaluate(scope)
}
return rets.reject { |o| o.nil? }
end
diff --git a/lib/puppet/parser/ast/caseopt.rb b/lib/puppet/parser/ast/caseopt.rb
index d1d9d0e9c..824bde853 100644
--- a/lib/puppet/parser/ast/caseopt.rb
+++ b/lib/puppet/parser/ast/caseopt.rb
@@ -44,17 +44,17 @@ class Puppet::Parser::AST
def eachvalue(scope)
if @value.is_a?(AST::ASTArray)
@value.each { |subval|
- yield subval.evaluate(:scope => scope)
+ yield subval.safeevaluate(scope)
}
else
- yield @value.evaluate(:scope => scope)
+ yield @value.safeevaluate(scope)
end
end
# Evaluate the actual statements; this only gets called if
# our option matched.
- def evaluate(hash)
- return @statements.safeevaluate(hash)
+ def evaluate(scope)
+ return @statements.safeevaluate(scope)
end
end
end
diff --git a/lib/puppet/parser/ast/casestatement.rb b/lib/puppet/parser/ast/casestatement.rb
index 3c6f9c7e2..aa03090de 100644
--- a/lib/puppet/parser/ast/casestatement.rb
+++ b/lib/puppet/parser/ast/casestatement.rb
@@ -8,9 +8,8 @@ class Puppet::Parser::AST
# Short-curcuit evaluation. Return the value of the statements for
# the first option that matches.
- def evaluate(hash)
- scope = hash[:scope]
- value = @test.safeevaluate(:scope => scope)
+ def evaluate(scope)
+ value = @test.safeevaluate(scope)
sensitive = Puppet[:casesensitive]
value = value.downcase if ! sensitive and value.respond_to?(:downcase)
@@ -30,7 +29,7 @@ class Puppet::Parser::AST
if found
# we found a matching option
- retvalue = option.safeevaluate(:scope => scope)
+ retvalue = option.safeevaluate(scope)
break
end
@@ -42,7 +41,7 @@ class Puppet::Parser::AST
# Unless we found something, look for the default.
unless found
if default
- retvalue = default.safeevaluate(:scope => scope)
+ retvalue = default.safeevaluate(scope)
else
Puppet.debug "No true answers and no default"
retvalue = nil
diff --git a/lib/puppet/parser/ast/collection.rb b/lib/puppet/parser/ast/collection.rb
index e05977a47..31f508929 100644
--- a/lib/puppet/parser/ast/collection.rb
+++ b/lib/puppet/parser/ast/collection.rb
@@ -9,11 +9,9 @@ class Collection < AST::Branch
attr_accessor :type, :query, :form
# We return an object that does a late-binding evaluation.
- def evaluate(hash)
- scope = hash[:scope]
-
+ def evaluate(scope)
if self.query
- str, code = self.query.safeevaluate :scope => scope
+ str, code = self.query.safeevaluate scope
else
str = code = nil
end
diff --git a/lib/puppet/parser/ast/collexpr.rb b/lib/puppet/parser/ast/collexpr.rb
index 4a96d9c61..3e13d9400 100644
--- a/lib/puppet/parser/ast/collexpr.rb
+++ b/lib/puppet/parser/ast/collexpr.rb
@@ -9,9 +9,7 @@ class CollExpr < AST::Branch
attr_accessor :test1, :test2, :oper, :form, :type, :parens
# We return an object that does a late-binding evaluation.
- def evaluate(hash)
- scope = hash[:scope]
-
+ def evaluate(scope)
# Make sure our contained expressions have all the info they need.
[@test1, @test2].each do |t|
if t.is_a?(self.class)
@@ -21,8 +19,8 @@ class CollExpr < AST::Branch
end
# The code is only used for virtual lookups
- str1, code1 = @test1.safeevaluate :scope => scope
- str2, code2 = @test2.safeevaluate :scope => scope
+ str1, code1 = @test1.safeevaluate scope
+ str2, code2 = @test2.safeevaluate scope
# First build up the virtual code.
# If we're a conjunction operator, then we're calling code. I did
diff --git a/lib/puppet/parser/ast/definition.rb b/lib/puppet/parser/ast/definition.rb
index 3d6d6188c..2e39e7332 100644
--- a/lib/puppet/parser/ast/definition.rb
+++ b/lib/puppet/parser/ast/definition.rb
@@ -27,10 +27,7 @@ class Puppet::Parser::AST
false
end
- def evaluate(options)
- origscope = options[:scope]
- resource = options[:resource]
-
+ def evaluate(origscope, resource)
# Create a new scope.
scope = subscope(origscope, resource)
@@ -49,7 +46,7 @@ class Puppet::Parser::AST
set_resource_parameters(scope, resource)
if self.code
- return self.code.safeevaluate(:scope => scope)
+ return self.code.safeevaluate(scope)
else
return nil
end
@@ -181,7 +178,7 @@ class Puppet::Parser::AST
arg = symbolize(arg)
unless args.include?(arg)
if defined? default and ! default.nil?
- default = default.safeevaluate :scope => scope
+ default = default.safeevaluate scope
args[arg] = default
#Puppet.debug "Got default %s for %s in %s" %
# [default.inspect, arg.inspect, @name.inspect]
diff --git a/lib/puppet/parser/ast/else.rb b/lib/puppet/parser/ast/else.rb
index e76051372..affac625d 100644
--- a/lib/puppet/parser/ast/else.rb
+++ b/lib/puppet/parser/ast/else.rb
@@ -12,9 +12,8 @@ class Puppet::Parser::AST
# Evaluate the actual statements; this only gets called if
# our test was true matched.
- def evaluate(hash)
- scope = hash[:scope]
- return @statements.safeevaluate(:scope => scope)
+ def evaluate(scope)
+ return @statements.safeevaluate(scope)
end
end
end
diff --git a/lib/puppet/parser/ast/function.rb b/lib/puppet/parser/ast/function.rb
index 0cd1fff62..63d7c7abf 100644
--- a/lib/puppet/parser/ast/function.rb
+++ b/lib/puppet/parser/ast/function.rb
@@ -7,18 +7,11 @@ class Puppet::Parser::AST
@settor = true
- def evaluate(hash)
+ def evaluate(scope)
# We don't need to evaluate the name, because it's plaintext
+ args = @arguments.safeevaluate(scope)
- # Just evaluate the arguments
- scope = hash[:scope]
-
- args = @arguments.safeevaluate(:scope => scope)
-
- #exceptwrap :message => "Failed to execute %s" % @name,
- # :type => Puppet::ParseError do
- return scope.send("function_" + @name, args)
- #end
+ return scope.send("function_" + @name, args)
end
def initialize(hash)
diff --git a/lib/puppet/parser/ast/hostclass.rb b/lib/puppet/parser/ast/hostclass.rb
index 63900d0e3..42d13f4b2 100644
--- a/lib/puppet/parser/ast/hostclass.rb
+++ b/lib/puppet/parser/ast/hostclass.rb
@@ -20,9 +20,7 @@ class Puppet::Parser::AST
end
# Evaluate the code associated with this class.
- def evaluate(options)
- scope = options[:scope]
- raise(ArgumentError, "Classes require resources") unless options[:resource]
+ def evaluate(scope, resource)
# Verify that we haven't already been evaluated. This is
# what provides the singleton aspect.
if existing_scope = scope.compile.class_scope(self)
@@ -34,7 +32,7 @@ class Puppet::Parser::AST
pnames = nil
if pklass = self.parentobj
- pklass.safeevaluate :scope => scope, :resource => options[:resource]
+ pklass.safeevaluate(scope, resource)
scope = parent_scope(scope, pklass)
pnames = scope.namespaces
@@ -42,8 +40,8 @@ class Puppet::Parser::AST
# Don't create a subscope for the top-level class, since it already
# has its own scope.
- unless options[:resource].title == :main
- scope = subscope(scope, options[:resource])
+ unless resource.title == :main
+ scope = subscope(scope, resource)
end
if pnames
@@ -58,7 +56,7 @@ class Puppet::Parser::AST
# Now evaluate our code, yo.
if self.code
- return self.code.evaluate(:scope => scope)
+ return self.code.safeevaluate(scope)
else
return nil
end
diff --git a/lib/puppet/parser/ast/ifstatement.rb b/lib/puppet/parser/ast/ifstatement.rb
index 66a07b01f..afa2cd572 100644
--- a/lib/puppet/parser/ast/ifstatement.rb
+++ b/lib/puppet/parser/ast/ifstatement.rb
@@ -12,15 +12,14 @@ class Puppet::Parser::AST
# Short-curcuit evaluation. If we're true, evaluate our statements,
# else if there's an 'else' setting, evaluate it.
# the first option that matches.
- def evaluate(hash)
- scope = hash[:scope]
- value = @test.safeevaluate(:scope => scope)
+ def evaluate(scope)
+ value = @test.safeevaluate(scope)
if Puppet::Parser::Scope.true?(value)
- return @statements.safeevaluate(:scope => scope)
+ return @statements.safeevaluate(scope)
else
if defined? @else
- return @else.safeevaluate(:scope => scope)
+ return @else.safeevaluate(scope)
else
return nil
end
diff --git a/lib/puppet/parser/ast/leaf.rb b/lib/puppet/parser/ast/leaf.rb
index 225253061..c545c1e47 100644
--- a/lib/puppet/parser/ast/leaf.rb
+++ b/lib/puppet/parser/ast/leaf.rb
@@ -6,7 +6,7 @@ class Puppet::Parser::AST
attr_accessor :value, :type
# Return our value.
- def evaluate(hash)
+ def evaluate(scope)
return @value
end
@@ -35,14 +35,14 @@ class Puppet::Parser::AST
class String < AST::Leaf
# Interpolate the string looking for variables, and then return
# the result.
- def evaluate(hash)
- return hash[:scope].strinterp(@value, @file, @line)
+ def evaluate(scope)
+ return scope.strinterp(@value, @file, @line)
end
end
# An uninterpreted string.
class FlatString < AST::Leaf
- def evaluate(hash)
+ def evaluate(scope)
return @value
end
end
@@ -81,9 +81,9 @@ class Puppet::Parser::AST
class Variable < Name
# Looks up the value of the object in the scope tree (does
# not include syntactical constructs, like '$' and '{}').
- def evaluate(hash)
+ def evaluate(scope)
parsewrap do
- return hash[:scope].lookupvar(@value)
+ return scope.lookupvar(@value)
end
end
end
diff --git a/lib/puppet/parser/ast/node.rb b/lib/puppet/parser/ast/node.rb
index a296e43ba..3c5d44d1b 100644
--- a/lib/puppet/parser/ast/node.rb
+++ b/lib/puppet/parser/ast/node.rb
@@ -7,23 +7,15 @@ class Puppet::Parser::AST
@name = :node
attr_accessor :name
- def evaluate(options)
- scope = options[:scope]
-
- #pscope = if ! Puppet[:lexical] or options[:asparent]
- # @scope
- #else
- # origscope
- #end
-
+ def evaluate(scope, resource)
# We don't have to worry about the declarativeness of node parentage,
# because the entry point is always a single node definition.
if parent = self.parentobj
- scope = parent.safeevaluate :scope => scope, :resource => options[:resource]
+ scope = parent.safeevaluate scope, resource
end
scope = scope.newscope(
- :resource => options[:resource],
+ :resource => resource,
:keyword => @keyword,
:source => self,
:namespace => "" # nodes are always in ""
@@ -36,7 +28,7 @@ class Puppet::Parser::AST
# And then evaluate our code if we have any
if self.code
- @code.safeevaluate(:scope => scope)
+ @code.safeevaluate(scope)
end
return scope
diff --git a/lib/puppet/parser/ast/resource.rb b/lib/puppet/parser/ast/resource.rb
index c53ab0a68..606beb537 100644
--- a/lib/puppet/parser/ast/resource.rb
+++ b/lib/puppet/parser/ast/resource.rb
@@ -9,15 +9,13 @@ class Resource < AST::ResourceReference
# Does not actually return an object; instead sets an object
# in the current scope.
- def evaluate(options)
- scope = options[:scope]
-
+ def evaluate(scope)
# Evaluate all of the specified params.
paramobjects = @params.collect { |param|
- param.safeevaluate(:scope => scope)
+ param.safeevaluate(scope)
}
- objtitles = @title.safeevaluate(:scope => scope)
+ objtitles = @title.safeevaluate(scope)
# it's easier to always use an array, even for only one name
unless objtitles.is_a?(Array)
diff --git a/lib/puppet/parser/ast/resource_defaults.rb b/lib/puppet/parser/ast/resource_defaults.rb
index 8f9c1b8df..4856f0594 100644
--- a/lib/puppet/parser/ast/resource_defaults.rb
+++ b/lib/puppet/parser/ast/resource_defaults.rb
@@ -8,13 +8,11 @@ class Puppet::Parser::AST
# As opposed to ResourceDef, this stores each default for the given
# object type.
- def evaluate(hash)
- scope = hash[:scope]
-
+ def evaluate(scope)
# Use a resource reference to canonize the type
ref = Puppet::ResourceReference.new(@type, "whatever")
type = ref.type
- params = @params.safeevaluate(:scope => scope)
+ params = @params.safeevaluate(scope)
parsewrap do
scope.setdefaults(type, params)
diff --git a/lib/puppet/parser/ast/resource_override.rb b/lib/puppet/parser/ast/resource_override.rb
index 46c930902..d15f68608 100644
--- a/lib/puppet/parser/ast/resource_override.rb
+++ b/lib/puppet/parser/ast/resource_override.rb
@@ -17,17 +17,15 @@ class Puppet::Parser::AST
# Does not actually return an object; instead sets an object
# in the current scope.
- def evaluate(hash)
- scope = hash[:scope]
-
+ def evaluate(scope)
# Get our object reference.
- object = @object.safeevaluate(:scope => scope)
+ object = @object.safeevaluate(scope)
hash = {}
# Evaluate all of the specified params.
params = @params.collect { |param|
- param.safeevaluate(:scope => scope)
+ param.safeevaluate(scope)
}
# Now we just create a normal resource, but we call a very different
diff --git a/lib/puppet/parser/ast/resource_reference.rb b/lib/puppet/parser/ast/resource_reference.rb
index b06ea17be..4bb41165a 100644
--- a/lib/puppet/parser/ast/resource_reference.rb
+++ b/lib/puppet/parser/ast/resource_reference.rb
@@ -22,10 +22,8 @@ class Puppet::Parser::AST
# Evaluate our object, but just return a simple array of the type
# and name.
- def evaluate(hash)
- scope = hash[:scope]
-
- title = @title.safeevaluate(:scope => scope)
+ def evaluate(scope)
+ title = @title.safeevaluate(scope)
if @type.to_s.downcase == "class"
objtype = "class"
title = qualified_class(scope, title)
diff --git a/lib/puppet/parser/ast/resourceparam.rb b/lib/puppet/parser/ast/resourceparam.rb
index 8b1e7b367..c552a7ee5 100644
--- a/lib/puppet/parser/ast/resourceparam.rb
+++ b/lib/puppet/parser/ast/resourceparam.rb
@@ -10,12 +10,10 @@ class Puppet::Parser::AST
end
# Return the parameter and the value.
- def evaluate(hash)
- scope = hash[:scope]
-
+ def evaluate(scope)
return Puppet::Parser::Resource::Param.new(
:name => @param,
- :value => @value.safeevaluate(:scope => scope),
+ :value => @value.safeevaluate(scope),
:source => scope.source, :line => self.line, :file => self.file,
:add => self.add
)
diff --git a/lib/puppet/parser/ast/selector.rb b/lib/puppet/parser/ast/selector.rb
index d363ab7e4..399d405a3 100644
--- a/lib/puppet/parser/ast/selector.rb
+++ b/lib/puppet/parser/ast/selector.rb
@@ -11,13 +11,12 @@ class Puppet::Parser::AST
end
# Find the value that corresponds with the test.
- def evaluate(hash)
- scope = hash[:scope]
+ def evaluate(scope)
retvalue = nil
found = nil
# Get our parameter.
- paramvalue = @param.safeevaluate(:scope => scope)
+ paramvalue = @param.safeevaluate(scope)
sensitive = Puppet[:casesensitive]
@@ -33,13 +32,13 @@ class Puppet::Parser::AST
# Then look for a match in the options.
@values.each { |obj|
- param = obj.param.safeevaluate(:scope => scope)
+ param = obj.param.safeevaluate(scope)
if ! sensitive && param.respond_to?(:downcase)
param = param.downcase
end
if param == paramvalue
# we found a matching option
- retvalue = obj.value.safeevaluate(:scope => scope)
+ retvalue = obj.value.safeevaluate(scope)
found = true
break
elsif obj.param.is_a?(Default)
@@ -51,7 +50,7 @@ class Puppet::Parser::AST
# Unless we found something, look for the default.
unless found
if default
- retvalue = default.value.safeevaluate(:scope => scope)
+ retvalue = default.value.safeevaluate(scope)
else
self.fail Puppet::ParseError,
"No matching value for selector param '%s'" % paramvalue
diff --git a/lib/puppet/parser/ast/tag.rb b/lib/puppet/parser/ast/tag.rb
index e2882d2f0..2909504a7 100644
--- a/lib/puppet/parser/ast/tag.rb
+++ b/lib/puppet/parser/ast/tag.rb
@@ -8,10 +8,8 @@ class Puppet::Parser::AST
@name = :class
attr_accessor :type
- def evaluate(hash)
- scope = hash[:scope]
-
- types = @type.safeevaluate(:scope => scope)
+ def evaluate(scope)
+ types = @type.safeevaluate(scope)
types = [types] unless types.is_a? Array
diff --git a/lib/puppet/parser/ast/vardef.rb b/lib/puppet/parser/ast/vardef.rb
index 1e7f874bc..ee79159d7 100644
--- a/lib/puppet/parser/ast/vardef.rb
+++ b/lib/puppet/parser/ast/vardef.rb
@@ -9,10 +9,9 @@ class Puppet::Parser::AST
# Look up our name and value, and store them appropriately. The
# lexer strips off the syntax stuff like '$'.
- def evaluate(hash)
- scope = hash[:scope]
- name = @name.safeevaluate(:scope => scope)
- value = @value.safeevaluate(:scope => scope)
+ def evaluate(scope)
+ name = @name.safeevaluate(scope)
+ value = @value.safeevaluate(scope)
parsewrap do
scope.setvar(name,value, @file, @line)
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb
index 58667727f..ea6038299 100644
--- a/lib/puppet/parser/resource.rb
+++ b/lib/puppet/parser/resource.rb
@@ -59,7 +59,7 @@ class Puppet::Parser::Resource
if klass = @ref.definedtype
finish()
scope.compile.delete_resource(self)
- return klass.evaluate(:scope => scope, :resource => self)
+ return klass.evaluate(scope, self)
elsif builtin?
devfail "Cannot evaluate a builtin type"
else
diff --git a/spec/unit/parser/ast/definition.rb b/spec/unit/parser/ast/definition.rb
index a27fb4721..1c84f5c5f 100755
--- a/spec/unit/parser/ast/definition.rb
+++ b/spec/unit/parser/ast/definition.rb
@@ -21,12 +21,12 @@ describe Puppet::Parser::AST::Definition, "when evaluating" do
it "should create a new scope" do
scope = nil
code = mock 'code'
- code.expects(:safeevaluate).with do |options|
- options[:scope].object_id.should_not == @scope.object_id
+ code.expects(:safeevaluate).with do |scope|
+ scope.object_id.should_not == @scope.object_id
true
end
@definition.stubs(:code).returns(code)
- @definition.evaluate(:scope => @scope, :resource => @resource)
+ @definition.evaluate(@scope, @resource)
end
# it "should copy its namespace to the scope"
diff --git a/spec/unit/parser/resource.rb b/spec/unit/parser/resource.rb
index 319d8f7d8..36e104fb1 100755
--- a/spec/unit/parser/resource.rb
+++ b/spec/unit/parser/resource.rb
@@ -21,20 +21,20 @@ describe Puppet::Parser::Resource, " when evaluating" do
it "should evaluate the associated AST definition" do
res = @type.new(:type => "mydefine", :title => "whatever", :scope => @scope, :source => @source)
- @definition.expects(:evaluate).with(:scope => @scope, :resource => res)
+ @definition.expects(:evaluate).with(@scope, res)
res.evaluate
end
it "should evaluate the associated AST class" do
res = @type.new(:type => "class", :title => "myclass", :scope => @scope, :source => @source)
- @class.expects(:evaluate).with(:scope => @scope, :resource => res)
+ @class.expects(:evaluate).with(@scope, res)
res.evaluate
end
it "should evaluate the associated AST node" do
res = @type.new(:type => "node", :title => "mynode", :scope => @scope, :source => @source)
- @nodedef.expects(:evaluate).with(:scope => @scope, :resource => res)
+ @nodedef.expects(:evaluate).with(@scope, res)
res.evaluate
end
end
diff --git a/test/language/ast.rb b/test/language/ast.rb
index b31012d38..72a3ee90c 100755
--- a/test/language/ast.rb
+++ b/test/language/ast.rb
@@ -35,14 +35,14 @@ class TestAST < Test::Unit::TestCase
# We initialized it to true, so we should get that first
ret = nil
assert_nothing_raised {
- ret = astif.evaluate(:scope => "yay")
+ ret = astif.evaluate("yay")
}
assert_equal(:if, ret)
# Now set it to false and check that
faketest.evaluate = false
assert_nothing_raised {
- ret = astif.evaluate(:scope => "yay")
+ ret = astif.evaluate("yay")
}
assert_equal(:else, ret)
end
@@ -60,7 +60,7 @@ class TestAST < Test::Unit::TestCase
scope.compile.expects(:store_override).with(:override)
ret = nil
assert_nothing_raised do
- ret = ref.evaluate :scope => scope
+ ret = ref.evaluate scope
end
assert_equal(:override, ret, "Did not return override")
@@ -74,7 +74,7 @@ class TestAST < Test::Unit::TestCase
args = {:source => "/yay/ness", :group => "yayness"}
assert_nothing_raised do
obj = defaultobj "file", args
- obj.evaluate :scope => scope
+ obj.evaluate scope
end
hash = nil
@@ -119,7 +119,7 @@ class TestAST < Test::Unit::TestCase
# Now try evaluating the node
assert_nothing_raised do
- mynode.evaluate :scope => scope, :resource => scope.resource
+ mynode.evaluate scope, scope.resource
end
# Make sure that we can find each of the files
@@ -136,7 +136,7 @@ class TestAST < Test::Unit::TestCase
newscope = mkscope :parser => parser
assert_nothing_raised do
- child.evaluate :scope => newscope, :resource => scope.resource
+ child.evaluate newscope, scope.resource
end
assert(newscope.findresource("File[/tmp/base]"),
@@ -155,7 +155,7 @@ class TestAST < Test::Unit::TestCase
ret = nil
assert_nothing_raised do
- ret = coll.evaluate :scope => scope
+ ret = coll.evaluate scope
end
assert_instance_of(Puppet::Parser::Collector, ret)
@@ -175,7 +175,7 @@ class TestAST < Test::Unit::TestCase
run_collection_queries(:virtual) do |string, result, query|
code = nil
assert_nothing_raised do
- str, code = query.evaluate :scope => scope
+ str, code = query.evaluate scope
end
assert_instance_of(Proc, code)
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
diff --git a/test/language/functions.rb b/test/language/functions.rb
index 132ee97ac..edb39e9a7 100755
--- a/test/language/functions.rb
+++ b/test/language/functions.rb
@@ -41,7 +41,7 @@ class TestLangFunctions < Test::Unit::TestCase
scope = mkscope
val = nil
assert_nothing_raised do
- val = func.evaluate(:scope => scope)
+ val = func.evaluate(scope)
end
assert_equal("output avalue", val)
@@ -57,7 +57,7 @@ class TestLangFunctions < Test::Unit::TestCase
val = nil
assert_nothing_raised do
- val = func.evaluate(:scope => scope)
+ val = func.evaluate(scope)
end
assert_equal(retval, val, "'tagged' returned %s for %s" % [val, tag])
@@ -86,7 +86,7 @@ class TestLangFunctions < Test::Unit::TestCase
scope = mkscope
val = nil
assert_raise(Puppet::ParseError) do
- val = func.evaluate(:scope => scope)
+ val = func.evaluate(scope)
end
end
@@ -117,16 +117,16 @@ class TestLangFunctions < Test::Unit::TestCase
scope = mkscope
assert_raise(Puppet::ParseError) do
- ast.evaluate(:scope => scope)
+ ast.evaluate(scope)
end
scope.setvar("one", "One")
assert_raise(Puppet::ParseError) do
- ast.evaluate(:scope => scope)
+ ast.evaluate(scope)
end
scope.setvar("two", "Two")
assert_nothing_raised do
- ast.evaluate(:scope => scope)
+ ast.evaluate(scope)
end
assert_equal("template One\ntemplate Two\n", scope.lookupvar("output"),
@@ -155,13 +155,13 @@ class TestLangFunctions < Test::Unit::TestCase
scope = mkscope
assert_raise(Puppet::ParseError) do
- ast.evaluate(:scope => scope)
+ ast.evaluate(scope)
end
scope.setvar("yayness", "this is yayness")
assert_nothing_raised do
- ast.evaluate(:scope => scope)
+ ast.evaluate(scope)
end
assert_equal("template this is yayness\n", scope.lookupvar("output"),
@@ -191,7 +191,7 @@ class TestLangFunctions < Test::Unit::TestCase
scope = mkscope
scope.setvar("myvar", "this is yayness")
assert_raise(Puppet::ParseError) do
- ast.evaluate(:scope => scope)
+ ast.evaluate(scope)
end
end
@@ -264,14 +264,14 @@ class TestLangFunctions < Test::Unit::TestCase
}.each do |string, value|
scope = mkscope
assert_raise(Puppet::ParseError) do
- ast.evaluate(:scope => scope)
+ ast.evaluate(scope)
end
scope.setvar("yayness", string)
assert_equal(string, scope.lookupvar("yayness", false))
assert_nothing_raised("An empty string was not a valid variable value") do
- ast.evaluate(:scope => scope)
+ ast.evaluate(scope)
end
assert_equal("template #{value}\n", scope.lookupvar("output"),
diff --git a/test/language/parser.rb b/test/language/parser.rb
index 1bbd894e4..3df4d0bb8 100755
--- a/test/language/parser.rb
+++ b/test/language/parser.rb
@@ -47,7 +47,7 @@ class TestParser < Test::Unit::TestCase
ast = parser.parse
config = mkcompile(parser)
config.compile
- #ast.classes[""].evaluate :scope => config.topscope
+ #ast.classes[""].evaluate config.topscope
}
Puppet::Type.allclear
}
@@ -891,7 +891,7 @@ file { "/tmp/yayness":
assert(parser.classes["myclass"], "Could not find definition")
assert_equal("myclass", parser.classes["myclass"].classname)
assert_equal(%w{original code},
- parser.classes["myclass"].code.evaluate(:scope => scope))
+ parser.classes["myclass"].code.evaluate(scope))
# Newclass behaves differently than the others -- it just appends
# the code to the existing class.
@@ -901,7 +901,7 @@ file { "/tmp/yayness":
end
assert(klass, "Did not return class when appending")
assert_equal(%w{original code something new},
- parser.classes["myclass"].code.evaluate(:scope => scope))
+ parser.classes["myclass"].code.evaluate(scope))
# Now create the same class name in a different scope
assert_nothing_raised {
@@ -914,7 +914,7 @@ file { "/tmp/yayness":
assert_equal("other::myclass", other.classname)
assert_equal("other::myclass", other.namespace)
assert_equal(%w{something diff},
- other.code.evaluate(:scope => scope))
+ other.code.evaluate(scope))
# Make sure newclass deals correctly with nodes with no code
klass = parser.newclass("nocode")
@@ -925,7 +925,7 @@ file { "/tmp/yayness":
end
assert(klass, "Did not return class with no code")
assert_equal(%w{yay test},
- parser.classes["nocode"].code.evaluate(:scope => scope))
+ parser.classes["nocode"].code.evaluate(scope))
# Then try merging something into nothing
parser.newclass("nocode2", :code => mkcode.call(%w{foo test}))
@@ -936,7 +936,7 @@ file { "/tmp/yayness":
end
assert(klass, "Did not return class with no code")
assert_equal(%w{foo test},
- parser.classes["nocode2"].code.evaluate(:scope => scope))
+ parser.classes["nocode2"].code.evaluate(scope))
# And lastly, nothing and nothing
klass = parser.newclass("nocode3")
diff --git a/test/language/resource.rb b/test/language/resource.rb
index 5a3916159..3c027ed07 100755
--- a/test/language/resource.rb
+++ b/test/language/resource.rb
@@ -270,8 +270,7 @@ class TestResource < PuppetTest::TestCase
res.scope.expects(:compile).returns(config)
config.expects(:delete_resource).with(res)
- args = {:scope => res.scope, :resource => res}
- type.expects(:evaluate).with(args)
+ type.expects(:evaluate).with(res.scope, res)
res.evaluate
end
diff --git a/test/language/scope.rb b/test/language/scope.rb
index ec11a864e..db9d465bf 100755
--- a/test/language/scope.rb
+++ b/test/language/scope.rb
@@ -284,7 +284,7 @@ class TestScope < Test::Unit::TestCase
)
assert_nothing_raised do
- function.evaluate :scope => scope
+ function.evaluate scope
end
scope.compile.send(:evaluate_generators)
@@ -379,7 +379,7 @@ class TestScope < Test::Unit::TestCase
obj.exported = true
# And then evaluate it
- obj.evaluate :scope => config.topscope
+ obj.evaluate config.topscope
# And run the loop.
config.send(:evaluate_generators)