diff options
Diffstat (limited to 'spec/ruby/core/proc/shared/equal.rb')
| -rw-r--r-- | spec/ruby/core/proc/shared/equal.rb | 49 |
1 files changed, 16 insertions, 33 deletions
diff --git a/spec/ruby/core/proc/shared/equal.rb b/spec/ruby/core/proc/shared/equal.rb index a5d067cea3..d0503fb064 100644 --- a/spec/ruby/core/proc/shared/equal.rb +++ b/spec/ruby/core/proc/shared/equal.rb @@ -13,7 +13,7 @@ describe :proc_equal, shared: true do p = Proc.new { :foo } p.send(@method, p).should be_true - p = lambda { :foo } + p = -> { :foo } p.send(@method, p).should be_true end @@ -24,7 +24,7 @@ describe :proc_equal, shared: true do p = Proc.new { :foo } p.send(@method, p.dup).should be_true - p = lambda { :foo } + p = -> { :foo } p.send(@method, p.dup).should be_true end @@ -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 - x = lambda { :foo } - x2 = lambda { :foo } - x.send(@method, x2).should be_true + it "returns false if lambdas are distinct but have same body and environment" do + x = -> { :foo } + x2 = -> { :foo } + x.send(@method, x2).should be_false end - it "returns true if both different kinds of procs with the same body and env" do - p = lambda { :foo } + 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 = lambda { :bar } - x.send(@method, x2).should be_true + x2 = -> { :bar } + x.send(@method, x2).should be_false end it "returns false if other is not a Proc" do @@ -65,7 +65,7 @@ describe :proc_equal, shared: true do p = Proc.new { :foo } p.send(@method, Object.new).should be_false - p = lambda { :foo } + p = -> { :foo } p.send(@method, :foo).should be_false end @@ -76,25 +76,8 @@ describe :proc_equal, shared: true do end it "returns false if self and other are both lambdas but have different bodies" do - p = lambda { :foo } - p2 = lambda { :bar } + p = -> { :foo } + p2 = -> { :bar } p.send(@method, p2).should be_false end end - -describe :proc_equal_undefined, shared: true do - it "is not defined" do - Proc.should_not have_instance_method(@method, false) - end - - it "returns false if other is a dup of the original" do - p = proc { :foo } - p.send(@method, p.dup).should be_false - - p = Proc.new { :foo } - p.send(@method, p.dup).should be_false - - p = lambda { :foo } - p.send(@method, p.dup).should be_false - end -end |
