summaryrefslogtreecommitdiff
path: root/test/ruby/test_proc.rb
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2021-06-15 10:06:52 -0700
committerJeremy Evans <code@jeremyevans.net>2021-06-24 12:25:33 -0700
commitbe230615d016e27d5b45b465d1481f6ecf7f1d28 (patch)
tree96ce3b8d68dcefe8372bc4d95561875dbfd94b98 /test/ruby/test_proc.rb
parent3ab68b910fc2c7bad0432892bddd9874e77ad35e (diff)
Remove shift of ep when computing Proc#hash
The shift was causing far fewer unique values of hash than expected. Fix pointed out by xtkoba (Tee KOBAYASHI) Fixes [Bug #17951]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4574
Diffstat (limited to 'test/ruby/test_proc.rb')
-rw-r--r--test/ruby/test_proc.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb
index 5f2f797992..16efd13d7c 100644
--- a/test/ruby/test_proc.rb
+++ b/test/ruby/test_proc.rb
@@ -159,6 +159,15 @@ class TestProc < Test::Unit::TestCase
assert_equal(*m_nest{}, "[ruby-core:84583] Feature #14627")
end
+ def test_hash
+ def self.capture(&block)
+ block
+ end
+
+ procs = Array.new(1000){capture{:foo }}
+ assert_operator(procs.map(&:hash).uniq.size, :>=, 500)
+ end
+
def test_block_par
assert_equal(10, Proc.new{|&b| b.call(10)}.call {|x| x})
assert_equal(12, Proc.new{|a,&b| b.call(a)}.call(12) {|x| x})