diff options
author | Peter Zhu <[email protected]> | 2024-10-31 11:02:11 -0400 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2024-11-01 10:49:50 -0400 |
commit | c7708d22c33040a74ea7ac683bf7407d3759edfe (patch) | |
tree | c2db6aeb442365849f887447d1ee15c4253b6164 /test/ruby | |
parent | 813286762c29e2f8d8f9cb077fecdac3a2ec7c09 (diff) |
Improve coverage of TestProc#test_hash_uniqueness
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11966
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_proc.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index 5f21c8cf5d..47b256a4c4 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -186,6 +186,18 @@ class TestProc < Test::Unit::TestCase procs = Array.new(1000){capture{:foo }} assert_operator(procs.map(&:hash).uniq.size, :>=, 500) + + # iseq backed proc + unique_hashes = 1000.times.map { proc {}.hash }.uniq + assert_operator(unique_hashes.size, :>=, 500) + + # ifunc backed proc + unique_hashes = 1000.times.map { {}.to_proc.hash }.uniq + assert_operator(unique_hashes.size, :>=, 500) + + # symbol backed proc + unique_hashes = 1000.times.map { |i| :"test#{i}".to_proc.hash }.uniq + assert_operator(unique_hashes.size, :>=, 500) end def test_hash_does_not_change_after_compaction |