Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
ko1 committed Dec 15, 2023
1 parent 7ba2506 commit 406d4bb
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/ruby/test_hash.rb
Expand Up @@ -2311,4 +2311,26 @@ def test_compare_by_identity_during_iteration
end
end
end

def test_ar_hash_to_st_hash
assert_normal_exit("#{<<~"begin;"}\n#{<<~'end;'}", 'https://bugs.ruby-lang.org/issues/20050#note-5')
begin;
srand(0)
class Foo
def to_a
[]
end
def hash
$h.delete($h.keys.sample) if rand < 0.1
to_a.hash
end
end
1000.times do
$h = {}
(0..10).each {|i| $h[Foo.new] ||= {} }
end
end;
end
end

0 comments on commit 406d4bb

Please sign in to comment.