diff options
author | Benoit Daloze <eregontp@gmail.com> | 2019-07-27 12:40:09 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2019-07-27 12:40:09 +0200 |
commit | 5c276e1cc91c5ab2a41fbf7827af2fed914a2bc0 (patch) | |
tree | 05b5c68c8b2a00224d4646ea3b26ce3877efaadd /spec/ruby/core/proc/shared | |
parent | a06301b103371b0b7da8eaca26ba744961769f99 (diff) |
Update to ruby/spec@875a09e
Diffstat (limited to 'spec/ruby/core/proc/shared')
-rw-r--r-- | spec/ruby/core/proc/shared/call.rb | 28 | ||||
-rw-r--r-- | spec/ruby/core/proc/shared/call_arguments.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/proc/shared/dup.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/proc/shared/equal.rb | 20 | ||||
-rw-r--r-- | spec/ruby/core/proc/shared/to_s.rb | 4 |
5 files changed, 28 insertions, 28 deletions
diff --git a/spec/ruby/core/proc/shared/call.rb b/spec/ruby/core/proc/shared/call.rb index 996d0e055d..c30ea84b23 100644 --- a/spec/ruby/core/proc/shared/call.rb +++ b/spec/ruby/core/proc/shared/call.rb @@ -3,7 +3,7 @@ require_relative '../fixtures/common' describe :proc_call, shared: true do it "invokes self" do Proc.new { "test!" }.send(@method).should == "test!" - lambda { "test!" }.send(@method).should == "test!" + -> { "test!" }.send(@method).should == "test!" proc { "test!" }.send(@method).should == "test!" end @@ -12,9 +12,9 @@ describe :proc_call, shared: true do Proc.new { |*args| args }.send(@method, 1, 2, 3, 4).should == [1, 2, 3, 4] Proc.new { |_, *args| args }.send(@method, 1, 2, 3).should == [2, 3] - lambda { |a, b| a + b }.send(@method, 1, 2).should == 3 - lambda { |*args| args }.send(@method, 1, 2, 3, 4).should == [1, 2, 3, 4] - lambda { |_, *args| args }.send(@method, 1, 2, 3).should == [2, 3] + -> a, b { a + b }.send(@method, 1, 2).should == 3 + -> *args { args }.send(@method, 1, 2, 3, 4).should == [1, 2, 3, 4] + -> _, *args { args }.send(@method, 1, 2, 3).should == [2, 3] proc { |a, b| a + b }.send(@method, 1, 2).should == 3 proc { |*args| args }.send(@method, 1, 2, 3, 4).should == [1, 2, 3, 4] @@ -65,28 +65,28 @@ describe :proc_call_on_proc_or_lambda, shared: true do end it "raises an ArgumentError on excess arguments when self is a lambda" do - lambda { - lambda {|x| x}.send(@method, 1, 2) + -> { + -> x { x }.send(@method, 1, 2) }.should raise_error(ArgumentError) - lambda { - lambda {|x| x}.send(@method, 1, 2, 3) + -> { + -> x { x }.send(@method, 1, 2, 3) }.should raise_error(ArgumentError) end it "raises an ArgumentError on missing arguments when self is a lambda" do - lambda { - lambda {|x| x}.send(@method) + -> { + -> x { x }.send(@method) }.should raise_error(ArgumentError) - lambda { - lambda {|x,y| [x,y]}.send(@method, 1) + -> { + -> x, y { [x,y] }.send(@method, 1) }.should raise_error(ArgumentError) end it "treats a single Array argument as a single argument when self is a lambda" do - lambda { |a| a }.send(@method, [1, 2]).should == [1, 2] - lambda { |a, b| [a, b] }.send(@method, [1, 2], 3).should == [[1,2], 3] + -> a { a }.send(@method, [1, 2]).should == [1, 2] + -> a, b { [a, b] }.send(@method, [1, 2], 3).should == [[1,2], 3] end it "treats a single Array argument as a single argument when self is a proc" do diff --git a/spec/ruby/core/proc/shared/call_arguments.rb b/spec/ruby/core/proc/shared/call_arguments.rb index a937bd99d0..ef6ec04620 100644 --- a/spec/ruby/core/proc/shared/call_arguments.rb +++ b/spec/ruby/core/proc/shared/call_arguments.rb @@ -1,7 +1,7 @@ describe :proc_call_block_args, shared: true do it "can receive block arguments" do Proc.new {|&b| b.send(@method)}.send(@method) {1 + 1}.should == 2 - lambda {|&b| b.send(@method)}.send(@method) {1 + 1}.should == 2 + ->&b { b.send(@method)}.send(@method) {1 + 1}.should == 2 proc {|&b| b.send(@method)}.send(@method) {1 + 1}.should == 2 end diff --git a/spec/ruby/core/proc/shared/dup.rb b/spec/ruby/core/proc/shared/dup.rb index fb6fff299d..eda1d6929d 100644 --- a/spec/ruby/core/proc/shared/dup.rb +++ b/spec/ruby/core/proc/shared/dup.rb @@ -1,6 +1,6 @@ describe :proc_dup, shared: true do it "returns a copy of self" do - a = lambda { "hello" } + a = -> { "hello" } b = a.send(@method) a.should_not equal(b) diff --git a/spec/ruby/core/proc/shared/equal.rb b/spec/ruby/core/proc/shared/equal.rb index a5d067cea3..46a1894424 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 @@ -43,18 +43,18 @@ describe :proc_equal, shared: true do end it "returns true if both lambdas with the same body and environment" do - x = lambda { :foo } - x2 = lambda { :foo } + x = -> { :foo } + x2 = -> { :foo } x.send(@method, x2).should be_true end it "returns true if both different kinds of procs with the same body and env" do - p = lambda { :foo } + p = -> { :foo } p2 = proc { :foo } p.send(@method, p2).should be_true x = proc { :bar } - x2 = lambda { :bar } + x2 = -> { :bar } x.send(@method, x2).should be_true end @@ -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,8 +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 @@ -94,7 +94,7 @@ describe :proc_equal_undefined, shared: true do p = Proc.new { :foo } p.send(@method, p.dup).should be_false - p = lambda { :foo } + p = -> { :foo } p.send(@method, p.dup).should be_false end end diff --git a/spec/ruby/core/proc/shared/to_s.rb b/spec/ruby/core/proc/shared/to_s.rb index 59fcf5bef0..a4d1d5d630 100644 --- a/spec/ruby/core/proc/shared/to_s.rb +++ b/spec/ruby/core/proc/shared/to_s.rb @@ -11,11 +11,11 @@ describe :proc_to_s, shared: true do describe "for a proc created with lambda" do it "returns a description including '(lambda)' and optionally including file and line number" do - lambda { "hello" }.send(@method).should =~ /^#<Proc:([^ ]*?)(@([^ ]*)\/to_s\.rb:10)? \(lambda\)>$/ + -> { "hello" }.send(@method).should =~ /^#<Proc:([^ ]*?)(@([^ ]*)\/to_s\.rb:10)? \(lambda\)>$/ end it "has a binary encoding" do - lambda { "hello" }.send(@method).encoding.should == Encoding::BINARY + -> { "hello" }.send(@method).encoding.should == Encoding::BINARY end end |