[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

test branch puppet-dev at googlegroups.com
Wed Jul 14 10:35:05 UTC 2010


The following commit has been merged in the upstream branch:
commit fb5c1d7bbe629df6214af9b47e522fb282983beb
Author: Brice Figureau <brice-puppet at daysofwonder.com>
Date:   Sun Jun 6 15:40:44 2010 +0200

    Fix #3907 - Hash couldn't be initialized with an empty hash
    
    The following manifest was failing:
    $data = {}
    
    This patch makes sure we initalize our ast hash with an empty ruby
    hash when it is created without any values.
    
    Signed-off-by: Brice Figureau <brice-puppet at daysofwonder.com>

diff --git a/lib/puppet/parser/ast/asthash.rb b/lib/puppet/parser/ast/asthash.rb
index aa5127d..d049019 100644
--- a/lib/puppet/parser/ast/asthash.rb
+++ b/lib/puppet/parser/ast/asthash.rb
@@ -28,5 +28,10 @@ class Puppet::Parser::AST
         def to_s
             "{" + @value.collect { |v| v.collect { |a| a.to_s }.join(' => ') }.join(', ') + "}"
         end
+
+        def initialize(args)
+            super(args)
+            @value ||= {}
+        end
     end
 end
diff --git a/spec/unit/parser/ast/asthash.rb b/spec/unit/parser/ast/asthash.rb
index c6839ab..fc8e1c7 100644
--- a/spec/unit/parser/ast/asthash.rb
+++ b/spec/unit/parser/ast/asthash.rb
@@ -78,6 +78,18 @@ describe Puppet::Parser::AST::ASTHash do
         operator.evaluate(@scope).should == { key1 => "b", key2 => "d" }
     end
 
+    describe "when being initialized without arguments" do
+        it "should evaluate to an empty hash" do
+            hash = Puppet::Parser::AST::ASTHash.new({})
+            hash.evaluate(@scope).should == {}
+        end
+
+        it "should support merging" do
+            hash = Puppet::Parser::AST::ASTHash.new({})
+            hash.merge({"a" => "b"}).should == {"a" => "b"}
+        end
+    end
+
     it "should return a valid string with to_s" do
         hash = Puppet::Parser::AST::ASTHash.new(:value => { "a" => "b", "c" => "d" })
 

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list