summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2025-05-14 10:37:59 +0900
committerNobuyoshi Nakada <[email protected]>2025-05-14 10:37:59 +0900
commit7793b59c8d2a13c124fe276e11723db23facce04 (patch)
tree2c60f53a310d2d9d4463e06decfe5b144d92cebf /test/ruby
parent7f5b4fb26ea8c0a736a37101327905eebebee8bf (diff)
[Bug #21331] Prohibit hash modification during stlike loop
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/13329
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_hash.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index b6c18ea958..76af5b6183 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -1853,6 +1853,14 @@ class TestHash < Test::Unit::TestCase
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)
+
+ x = (1..1337).to_h {|k| [k, k]}
+ assert_raise_with_message(RuntimeError, /rehash during iteration/) do
+ x.transform_values! {|v|
+ x.rehash if v == 1337
+ v * 2
+ }
+ end
end
def hrec h, n, &b