Improve coverage of TestProc#test_hash_uniqueness

This commit is contained in:
Peter Zhu 2024-10-31 11:02:11 -04:00
parent 813286762c
commit c7708d22c3
Notes: git 2024-11-01 14:50:10 +00:00

View File

@ -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