Skip to content

Commit 8132867

Browse files
committed
Add TestProc#test_hash_equal
1 parent 53b3fac commit 8132867

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/ruby/test_proc.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,26 @@ def test_eq
159159
assert_equal(*m_nest{}, "[ruby-core:84583] Feature #14627")
160160
end
161161

162+
def test_hash_equal
163+
# iseq backed proc
164+
p1 = proc {}
165+
p2 = p1.dup
166+
167+
assert_equal p1.hash, p2.hash
168+
169+
# ifunc backed proc
170+
p1 = {}.to_proc
171+
p2 = p1.dup
172+
173+
assert_equal p1.hash, p2.hash
174+
175+
# symbol backed proc
176+
p1 = :hello.to_proc
177+
p2 = :hello.to_proc
178+
179+
assert_equal p1.hash, p2.hash
180+
end
181+
162182
def test_hash_uniqueness
163183
def self.capture(&block)
164184
block

0 commit comments

Comments
 (0)