From 59cd24d41f1e6b5e25d35103c0720e8aa8cae0b6 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 4 Apr 2014 12:14:23 +0900 Subject: Hash#replace should copy default as well; close #2004 --- test/t/hash.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test') diff --git a/test/t/hash.rb b/test/t/hash.rb index ec9da8ca7..8a10f4026 100644 --- a/test/t/hash.rb +++ b/test/t/hash.rb @@ -230,6 +230,15 @@ assert('Hash#replace', '15.2.13.4.23') do b = Hash.new.replace(a) assert_equal({ 'abc_key' => 'abc_value' }, b) + + a = Hash.new(42) + b = {} + b.replace(a) + assert_equal(42, b[1]) + + a = Hash.new{|h,x| x} + b.replace(a) + assert_equal(127, b[127]) end assert('Hash#shift', '15.2.13.4.24') do -- cgit v1.2.3