From 878af5147def7fed089d3cc388742f0111db58ae Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Mon, 1 Jun 2020 12:28:05 -0700 Subject: Implement Proc#== and #eql? Previously, these were not implemented, and Object#== and #eql? were used. This tries to check the proc internals to make sure that procs created from separate blocks are treated as not equal, but procs created from the same block are treated as equal, even when the lazy proc allocation optimization is used. Implements [Feature #14267] --- test/ruby/test_proc.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index 765b400dbe..0cc5d488c2 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -137,6 +137,14 @@ class TestProc < Test::Unit::TestCase lambda { x } end + def m_nest0(&block) + block + end + + def m_nest(&block) + [m_nest0(&block), m_nest0(&block)] + end + def test_eq a = m(1) b = m(2) @@ -148,6 +156,8 @@ class TestProc < Test::Unit::TestCase a = lambda {|x| lambda {} }.call(1) b = lambda {} assert_not_equal(a, b, "[ruby-dev:22601]") + + assert_equal(*m_nest{}, "[ruby-core:84583] Feature #14627") end def test_block_par -- cgit v1.2.3