diff options
author | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-26 01:33:45 +0000 |
---|---|---|
committer | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-26 01:33:45 +0000 |
commit | 52bb93c25a13600e9c7cc35f658db09b3ed349c4 (patch) | |
tree | c2d354325f138d075e6847cc7bb639b131e5af24 /test/ruby/test_hash.rb | |
parent | d00ef6b3cd294f230fca1108b2fcd29e88e295d4 (diff) | |
download | ruby-52bb93c25a13600e9c7cc35f658db09b3ed349c4.tar.gz |
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
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_hash.rb')
-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 313c2fd9de..55e46584b4 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1576,6 +1576,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 |