summaryrefslogtreecommitdiff
path: root/test/ruby/test_proc.rb
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2020-06-01 12:28:05 -0700
committerJeremy Evans <code@jeremyevans.net>2020-06-19 12:58:25 -0700
commit878af5147def7fed089d3cc388742f0111db58ae (patch)
tree93e6e68b6b40575f7a1f3a641383c4111f05ef08 /test/ruby/test_proc.rb
parentb3aff6a11cbc96e5fc6c615d3f7a7a11fda6f59a (diff)
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]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3174
Diffstat (limited to 'test/ruby/test_proc.rb')
-rw-r--r--test/ruby/test_proc.rb10
1 files changed, 10 insertions, 0 deletions
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