summaryrefslogtreecommitdiff
path: root/spec/ruby/core/proc/shared
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 /spec/ruby/core/proc/shared
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 'spec/ruby/core/proc/shared')
-rw-r--r--spec/ruby/core/proc/shared/equal.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/spec/ruby/core/proc/shared/equal.rb b/spec/ruby/core/proc/shared/equal.rb
index 46a1894424..0c0020ca7f 100644
--- a/spec/ruby/core/proc/shared/equal.rb
+++ b/spec/ruby/core/proc/shared/equal.rb
@@ -36,26 +36,26 @@ describe :proc_equal, shared: true do
a.send(@method, b).should be_false
end
- it "returns true if both procs have the same body and environment" do
+ it "returns false if procs are distinct but have the same body and environment" do
p = proc { :foo }
p2 = proc { :foo }
- p.send(@method, p2).should be_true
+ p.send(@method, p2).should be_false
end
- it "returns true if both lambdas with the same body and environment" do
+ it "returns false if lambdas are distinct but have same body and environment" do
x = -> { :foo }
x2 = -> { :foo }
- x.send(@method, x2).should be_true
+ x.send(@method, x2).should be_false
end
- it "returns true if both different kinds of procs with the same body and env" do
+ it "returns false if using comparing lambda to proc, even with the same body and env" do
p = -> { :foo }
p2 = proc { :foo }
- p.send(@method, p2).should be_true
+ p.send(@method, p2).should be_false
x = proc { :bar }
x2 = -> { :bar }
- x.send(@method, x2).should be_true
+ x.send(@method, x2).should be_false
end
it "returns false if other is not a Proc" do