From 547176267f8378a193774c4ca529e854e811c928 Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 22 Mar 2018 07:00:17 +0000 Subject: merge revision(s) 62042,62044: [Backport #14380] hash.c: support key swapping in Hash#transform_keys! * hash.c (rb_hash_transform_keys_bang): support key swapping in Hash#transform_keys! [Bug #14380] [ruby-core:84951] * test/ruby/test_hash.rb (test_transform_keys_bang): add assertions for this change Fix rubyspec against the change in Hash#transform_keys! [Bug #14380] [ruby-core:84951] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@62889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- spec/ruby/core/hash/transform_keys_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'spec') diff --git a/spec/ruby/core/hash/transform_keys_spec.rb b/spec/ruby/core/hash/transform_keys_spec.rb index 379638bd4b..cf42f17e51 100644 --- a/spec/ruby/core/hash/transform_keys_spec.rb +++ b/spec/ruby/core/hash/transform_keys_spec.rb @@ -60,9 +60,9 @@ ruby_version_is "2.5" do @hash.should == { 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4 } end - it "does not prevent conflicts between new keys and old ones" do + it "prevents conflicts between new keys and old ones" do @hash.transform_keys!(&:succ) - @hash.should == { e: 1 } + @hash.should == { b: 1, c: 2, d: 3, e: 4 } end it "partially modifies the contents if we broke from the block" do @@ -70,7 +70,7 @@ ruby_version_is "2.5" do break if v == :c v.succ end - @hash.should == { c: 1, d: 4 } + @hash.should == { b: 1, c: 2 } end it "keeps later pair if new keys conflict" do -- cgit v1.2.3