summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorPaul Berry <paul@puppetlabs.com>2010-09-17 16:42:40 -0700
committerMarkus Roberts <Markus@reality.com>2010-09-22 21:11:29 -0700
commit8cd1540f82cbdf903c164bdbc2c7229e34a4178b (patch)
tree130e40b4d2696e70d1b348946c56f7a5ab213cb0 /spec
parent06bf566cf71b5a690c61887dff0538922b026f64 (diff)
downloadpuppet-8cd1540f82cbdf903c164bdbc2c7229e34a4178b.tar.gz
puppet-8cd1540f82cbdf903c164bdbc2c7229e34a4178b.tar.xz
puppet-8cd1540f82cbdf903c164bdbc2c7229e34a4178b.zip
[#4692] undefined variables cause :undef to be passed to functions
The :undef symbol, which we use internally to distinguish between undefined variables and variables whose value is the empty string, is being leaked in calls to functions (e.g. "split"). This is a departure from 0.25.x behavior, where undefined variables evaluated to "". This patch restores the 0.25.x behavior.
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/parser/ast/function_spec.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/spec/unit/parser/ast/function_spec.rb b/spec/unit/parser/ast/function_spec.rb
index c57c7f098..38e344157 100644
--- a/spec/unit/parser/ast/function_spec.rb
+++ b/spec/unit/parser/ast/function_spec.rb
@@ -61,20 +61,30 @@ describe Puppet::Parser::AST::Function do
end
it "should call the underlying ruby function" do
- argument = stub 'arg', :safeevaluate => "nothing"
+ argument = stub 'arg', :safeevaluate => ["nothing"]
Puppet::Parser::Functions.stubs(:function).with("exist").returns(true)
func = Puppet::Parser::AST::Function.new :name => "exist", :ftype => :statement, :arguments => argument
- @scope.expects(:function_exist).with("nothing")
+ @scope.expects(:function_exist).with(["nothing"])
+
+ func.evaluate(@scope)
+ end
+
+ it "should convert :undef to '' in arguments" do
+ argument = stub 'arg', :safeevaluate => ["foo", :undef, "bar"]
+ Puppet::Parser::Functions.stubs(:function).with("exist").returns(true)
+ func = Puppet::Parser::AST::Function.new :name => "exist", :ftype => :statement, :arguments => argument
+
+ @scope.expects(:function_exist).with(["foo", "", "bar"])
func.evaluate(@scope)
end
it "should return the ruby function return for rvalue functions" do
- argument = stub 'arg', :safeevaluate => "nothing"
+ argument = stub 'arg', :safeevaluate => ["nothing"]
Puppet::Parser::Functions.stubs(:function).with("exist").returns(true)
func = Puppet::Parser::AST::Function.new :name => "exist", :ftype => :statement, :arguments => argument
- @scope.stubs(:function_exist).with("nothing").returns("returning")
+ @scope.stubs(:function_exist).with(["nothing"]).returns("returning")
func.evaluate(@scope).should == "returning"
end