[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-663-g71824ee
Markus Roberts
Markus at reality.com
Tue Jul 20 07:42:45 UTC 2010
The following commit has been merged in the upstream branch:
commit 06fc40c5d755a41c8ece84a3d437572a64b4c899
Author: Nick Lewis <nick at puppetlabs.com>
Date: Mon Jul 19 12:32:46 2010 -0700
[#4269] Undef variables interpolate to empty string
This fixes double-quoted strings to interpolate undef variables
as an empty string. This is the behavior present in 0.25.x.
diff --git a/lib/puppet/parser/ast/leaf.rb b/lib/puppet/parser/ast/leaf.rb
index db9788f..49cde63 100644
--- a/lib/puppet/parser/ast/leaf.rb
+++ b/lib/puppet/parser/ast/leaf.rb
@@ -63,7 +63,7 @@ class Puppet::Parser::AST
class Concat < AST::Leaf
def evaluate(scope)
- @value.collect { |x| x.evaluate(scope) }.join
+ @value.collect { |x| x.evaluate(scope) }.collect{ |x| x == :undef ? '' : x }.join
end
def to_s
diff --git a/spec/unit/parser/ast/leaf_spec.rb b/spec/unit/parser/ast/leaf_spec.rb
index 6729cd2..5bdca67 100755
--- a/spec/unit/parser/ast/leaf_spec.rb
+++ b/spec/unit/parser/ast/leaf_spec.rb
@@ -50,6 +50,37 @@ describe Puppet::Parser::AST::String do
end
end
+describe Puppet::Parser::AST::Concat do
+ describe "when evaluating" do
+ before :each do
+ @scope = stub_everything 'scope'
+ end
+ it "should interpolate variables and concatenate their values" do
+ one = Puppet::Parser::AST::String.new(:value => "one")
+ one.stubs(:evaluate).returns("one ")
+ two = Puppet::Parser::AST::String.new(:value => "two")
+ two.stubs(:evaluate).returns(" two ")
+ three = Puppet::Parser::AST::String.new(:value => "three")
+ three.stubs(:evaluate).returns(" three")
+ var = Puppet::Parser::AST::Variable.new(:value => "myvar")
+ var.stubs(:evaluate).returns("foo")
+ array = Puppet::Parser::AST::Variable.new(:value => "array")
+ array.stubs(:evaluate).returns(["bar","baz"])
+ concat = Puppet::Parser::AST::Concat.new(:value => [one,var,two,array,three])
+
+ concat.evaluate(@scope).should == 'one foo two barbaz three'
+ end
+
+ it "should transform undef variables to empty string" do
+ var = Puppet::Parser::AST::Variable.new(:value => "myvar")
+ var.stubs(:evaluate).returns(:undef)
+ concat = Puppet::Parser::AST::Concat.new(:value => [var])
+
+ concat.evaluate(@scope).should == ''
+ end
+ end
+end
+
describe Puppet::Parser::AST::Undef do
before :each do
@scope = stub 'scope'
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list