summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKenichi Kamiya <kachick1@gmail.com>2021-03-22 14:10:52 +0900
committerGitHub <noreply@github.com>2021-03-22 14:10:52 +0900
commit7d3fdfb27dac456827b004d9e66a44b15f8cd762 (patch)
tree6875ffdbe8b19c41a94c2915dade052bcbf5011a /test
parentdb0ad48309edae28a65e3d18e9b3a15753eda777 (diff)
Hash#transform_values! ensures receiver modifiable in block [Bug #17736]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4302 Merged-By: nobu <nobu@ruby-lang.org>
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_hash.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index a6acbc6054..bd94b408bb 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -1803,6 +1803,15 @@ class TestHash < Test::Unit::TestCase
x = @cls[a: 1, b: 2, c: 3]
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))
+
+ x = @cls[a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9, j: 10]
+ assert_raise(FrozenError) do
+ x.transform_values!() do |v|
+ x.freeze if v == 2
+ v.succ
+ end
+ end
+ assert_equal(@cls[a: 2, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9, j: 10], x)
end
def test_broken_hash_value