diff options
Diffstat (limited to 'spec/ruby/language/method_spec.rb')
-rw-r--r-- | spec/ruby/language/method_spec.rb | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/spec/ruby/language/method_spec.rb b/spec/ruby/language/method_spec.rb index b0fc521d69..3e5ff3fbb5 100644 --- a/spec/ruby/language/method_spec.rb +++ b/spec/ruby/language/method_spec.rb @@ -40,7 +40,7 @@ describe "A method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { m(*x) }.should raise_error(TypeError) + -> { m(*x) }.should raise_error(TypeError) end end @@ -74,7 +74,7 @@ describe "A method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { m(*x, 2, 3) }.should raise_error(TypeError) + -> { m(*x, 2, 3) }.should raise_error(TypeError) end end @@ -108,7 +108,7 @@ describe "A method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { m(1, *x, 2, 3) }.should raise_error(TypeError) + -> { m(1, *x, 2, 3) }.should raise_error(TypeError) end it "copies the splatted array" do @@ -153,7 +153,7 @@ describe "A method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { m(1, 2, *x) }.should raise_error(TypeError) + -> { m(1, 2, *x) }.should raise_error(TypeError) end end end @@ -197,7 +197,7 @@ describe "An element assignment method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { @o[*x] = 1 }.should raise_error(TypeError) + -> { @o[*x] = 1 }.should raise_error(TypeError) end end @@ -235,7 +235,7 @@ describe "An element assignment method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { @o[*x, 2, 3] = 4 }.should raise_error(TypeError) + -> { @o[*x, 2, 3] = 4 }.should raise_error(TypeError) end end @@ -273,7 +273,7 @@ describe "An element assignment method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { @o[1, 2, *x, 3] = 4 }.should raise_error(TypeError) + -> { @o[1, 2, *x, 3] = 4 }.should raise_error(TypeError) end end @@ -311,7 +311,7 @@ describe "An element assignment method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { @o[1, 2, 3, *x] = 4 }.should raise_error(TypeError) + -> { @o[1, 2, 3, *x] = 4 }.should raise_error(TypeError) end end end @@ -348,7 +348,7 @@ describe "An attribute assignment method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { @o.send :m=, *x, 1 }.should raise_error(TypeError) + -> { @o.send :m=, *x, 1 }.should raise_error(TypeError) end end @@ -383,7 +383,7 @@ describe "An attribute assignment method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { @o.send :m=, *x, 2, 3, 4 }.should raise_error(TypeError) + -> { @o.send :m=, *x, 2, 3, 4 }.should raise_error(TypeError) end end @@ -418,7 +418,7 @@ describe "An attribute assignment method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { @o.send :m=, 1, 2, *x, 3, 4 }.should raise_error(TypeError) + -> { @o.send :m=, 1, 2, *x, 3, 4 }.should raise_error(TypeError) end end @@ -453,7 +453,7 @@ describe "An attribute assignment method send" do x = mock("splat argument") x.should_receive(:to_a).and_return(1) - lambda { @o.send :m=, 1, 2, 3, *x, 4 }.should raise_error(TypeError) + -> { @o.send :m=, 1, 2, 3, *x, 4 }.should raise_error(TypeError) end end end @@ -544,9 +544,9 @@ describe "A method" do def m(a:) a end ruby - lambda { m() }.should raise_error(ArgumentError) + -> { m() }.should raise_error(ArgumentError) m(a: 1).should == 1 - lambda { m("a" => 1, a: 1) }.should raise_error(ArgumentError) + -> { m("a" => 1, a: 1) }.should raise_error(ArgumentError) end evaluate <<-ruby do @@ -563,7 +563,7 @@ describe "A method" do m().should be_nil m(a: 1, b: 2).should be_nil - lambda { m(1) }.should raise_error(ArgumentError) + -> { m(1) }.should raise_error(ArgumentError) end evaluate <<-ruby do @@ -575,7 +575,7 @@ describe "A method" do m(*[]).should == {} m(**{}).should == {} m(**{a: 1, b: 2}, **{a: 4, c: 7}).should == { a: 4, b: 2, c: 7 } - lambda { m(2) }.should raise_error(ArgumentError) + -> { m(2) }.should raise_error(ArgumentError) end evaluate <<-ruby do @@ -614,7 +614,7 @@ describe "A method" do m(2, 3).should be_nil m([2, 3, 4], [5, 6]).should be_nil - lambda { m a: 1 }.should raise_error(ArgumentError) + -> { m a: 1 }.should raise_error(ArgumentError) end evaluate <<-ruby do @@ -706,7 +706,7 @@ describe "A method" do ruby m(1, b: 2).should == [1, 2] - lambda { m("a" => 1, b: 2) }.should raise_error(ArgumentError) + -> { m("a" => 1, b: 2) }.should raise_error(ArgumentError) end evaluate <<-ruby do @@ -808,8 +808,8 @@ describe "A method" do def m(a=1, (*b), (*c)) [a, b, c] end ruby - lambda { m() }.should raise_error(ArgumentError) - lambda { m(2) }.should raise_error(ArgumentError) + -> { m() }.should raise_error(ArgumentError) + -> { m(2) }.should raise_error(ArgumentError) m(2, 3).should == [1, [2], [3]] m(2, [3, 4], [5, 6]).should == [2, [3, 4], [5, 6]] end @@ -966,7 +966,7 @@ describe "A method" do h = mock("keyword splat") error = RuntimeError.new("error while converting to a hash") h.should_receive(:to_hash).and_raise(error) - lambda { m(h) }.should raise_error(error) + -> { m(h) }.should raise_error(error) end evaluate <<-ruby do @@ -980,7 +980,7 @@ describe "A method" do h = mock("keyword splat") h.should_receive(:to_hash) - lambda { m(**h) }.should raise_error(TypeError) + -> { m(**h) }.should raise_error(TypeError) end evaluate <<-ruby do @@ -1077,7 +1077,7 @@ describe "A method" do ruby m(a: 1, b: 2).should == [1, 2] - lambda { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError) + -> { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError) end evaluate <<-ruby do @@ -1086,7 +1086,7 @@ describe "A method" do m(a: 1).should == [1, 1] m(a: 1, b: 2).should == [1, 2] - lambda { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError) + -> { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError) end evaluate <<-ruby do @@ -1095,7 +1095,7 @@ describe "A method" do m(a: 1).should == 1 m(a: 1, b: 2).should == 1 - lambda { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError) + -> { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError) end evaluate <<-ruby do @@ -1104,7 +1104,7 @@ describe "A method" do m(a: 1).should == [1, {}] m(a: 1, b: 2, c: 3).should == [1, {b: 2, c: 3}] - lambda { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError) + -> { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError) end evaluate <<-ruby do @@ -1224,7 +1224,7 @@ describe "A method" do ruby options = {a: 1}.freeze - lambda do + -> do m(options).should == 1 end.should_not raise_error options.should == {a: 1} @@ -1259,11 +1259,11 @@ describe "A method call with a space between method name and parentheses" do context "when 2+ arguments provided" do it "raises a syntax error" do - lambda { + -> { eval("m (1, 2)") }.should raise_error(SyntaxError) - lambda { + -> { eval("m (1, 2, 3)") }.should raise_error(SyntaxError) end |