summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-01-10 21:26:43 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-01-10 21:44:38 +0900
commit1b4d406e3a04032b6d01e92b6d184a16945c6ac3 (patch)
treeda86f3fc92961cb4d675f6dad2b33ee5f7d96e8e /test
parent135b533e84ea04d0a494422efba635e5c9f2bfb2 (diff)
downloadruby-1b4d406e3a04032b6d01e92b6d184a16945c6ac3.tar.gz
Hash#transform_values should return a plain new Hash
[Bug #16498]
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_hash.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index 733bccd138..ef32cff868 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -1674,9 +1674,15 @@ class TestHash < Test::Unit::TestCase
def test_transform_values
x = @cls[a: 1, b: 2, c: 3]
+ x.default = 42
y = x.transform_values {|v| v ** 2 }
assert_equal([1, 4, 9], y.values_at(:a, :b, :c))
assert_not_same(x, y)
+ assert_nil(y.default)
+
+ x.default_proc = proc {|h, k| k}
+ y = x.transform_values {|v| v ** 2 }
+ assert_nil(y.default_proc)
y = x.transform_values.with_index {|v, i| "#{v}.#{i}" }
assert_equal(%w(1.0 2.1 3.2), y.values_at(:a, :b, :c))