diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-03-22 07:00:17 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-03-22 07:00:17 +0000 |
commit | 547176267f8378a193774c4ca529e854e811c928 (patch) | |
tree | d9d792c7d4cd23045d2daef4d9476da5e1940ddf /test | |
parent | f4aea9108d19b304e8a7f9d2ec4763eadf4a64ba (diff) |
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
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_hash.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 4223aa8140..bdcf022668 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1573,6 +1573,14 @@ class TestHash < Test::Unit::TestCase x.transform_keys!.with_index {|k, i| "#{k}.#{i}" } assert_equal(%w(a!.0 b!.1 c!.2), x.keys) + + x = @cls[1 => :a, -1 => :b] + x.transform_keys! {|k| -k } + assert_equal([-1, :a, 1, :b], x.flatten) + + x = @cls[true => :a, false => :b] + x.transform_keys! {|k| !k } + assert_equal([false, :a, true, :b], x.flatten) end def test_transform_values |