diff options
Diffstat (limited to 'spec/ruby/core/integer')
37 files changed, 219 insertions, 206 deletions
diff --git a/spec/ruby/core/integer/allbits_spec.rb b/spec/ruby/core/integer/allbits_spec.rb index d7bd58d638..f4a6fe9905 100644 --- a/spec/ruby/core/integer/allbits_spec.rb +++ b/spec/ruby/core/integer/allbits_spec.rb @@ -28,12 +28,12 @@ ruby_version_is '2.5' do end it "raises a TypeError when given a non-Integer" do - lambda { + -> { (obj = mock('10')).should_receive(:coerce).any_number_of_times.and_return([42,10]) 13.allbits?(obj) }.should raise_error(TypeError) - lambda { 13.allbits?("10") }.should raise_error(TypeError) - lambda { 13.allbits?(:symbol) }.should raise_error(TypeError) + -> { 13.allbits?("10") }.should raise_error(TypeError) + -> { 13.allbits?(:symbol) }.should raise_error(TypeError) end end end diff --git a/spec/ruby/core/integer/anybits_spec.rb b/spec/ruby/core/integer/anybits_spec.rb index 36803694aa..91f349258a 100644 --- a/spec/ruby/core/integer/anybits_spec.rb +++ b/spec/ruby/core/integer/anybits_spec.rb @@ -27,12 +27,12 @@ ruby_version_is '2.5' do end it "raises a TypeError when given a non-Integer" do - lambda { + -> { (obj = mock('10')).should_receive(:coerce).any_number_of_times.and_return([42,10]) 13.anybits?(obj) }.should raise_error(TypeError) - lambda { 13.anybits?("10") }.should raise_error(TypeError) - lambda { 13.anybits?(:symbol) }.should raise_error(TypeError) + -> { 13.anybits?("10") }.should raise_error(TypeError) + -> { 13.anybits?(:symbol) }.should raise_error(TypeError) end end end diff --git a/spec/ruby/core/integer/bit_and_spec.rb b/spec/ruby/core/integer/bit_and_spec.rb index 8565f82397..15a8026855 100644 --- a/spec/ruby/core/integer/bit_and_spec.rb +++ b/spec/ruby/core/integer/bit_and_spec.rb @@ -35,14 +35,14 @@ describe "Integer#&" do end it "raises a TypeError when passed a Float" do - lambda { (3 & 3.4) }.should raise_error(TypeError) + -> { (3 & 3.4) }.should raise_error(TypeError) end it "raises a TypeError and does not call #to_int when defined on an object" do obj = mock("fixnum bit and") obj.should_not_receive(:to_int) - lambda { 3 & obj }.should raise_error(TypeError) + -> { 3 & obj }.should raise_error(TypeError) end end @@ -84,14 +84,14 @@ describe "Integer#&" do end it "raises a TypeError when passed a Float" do - lambda { (@bignum & 3.4) }.should raise_error(TypeError) + -> { (@bignum & 3.4) }.should raise_error(TypeError) end it "raises a TypeError and does not call #to_int when defined on an object" do obj = mock("bignum bit and") obj.should_not_receive(:to_int) - lambda { @bignum & obj }.should raise_error(TypeError) + -> { @bignum & obj }.should raise_error(TypeError) end end end diff --git a/spec/ruby/core/integer/bit_or_spec.rb b/spec/ruby/core/integer/bit_or_spec.rb index 16ab430f8b..e486eeec10 100644 --- a/spec/ruby/core/integer/bit_or_spec.rb +++ b/spec/ruby/core/integer/bit_or_spec.rb @@ -15,14 +15,14 @@ describe "Integer#|" do end it "raises a TypeError when passed a Float" do - lambda { (3 | 3.4) }.should raise_error(TypeError) + -> { (3 | 3.4) }.should raise_error(TypeError) end it "raises a TypeError and does not call #to_int when defined on an object" do obj = mock("integer bit or") obj.should_not_receive(:to_int) - lambda { 3 | obj }.should raise_error(TypeError) + -> { 3 | obj }.should raise_error(TypeError) end end @@ -51,18 +51,18 @@ describe "Integer#|" do it "raises a TypeError when passed a Float" do not_supported_on :opal do - lambda { + -> { bignum_value | bignum_value(0xffff).to_f }.should raise_error(TypeError) end - lambda { @bignum | 9.9 }.should raise_error(TypeError) + -> { @bignum | 9.9 }.should raise_error(TypeError) end it "raises a TypeError and does not call #to_int when defined on an object" do obj = mock("bignum bit or") obj.should_not_receive(:to_int) - lambda { @bignum | obj }.should raise_error(TypeError) + -> { @bignum | obj }.should raise_error(TypeError) end end end diff --git a/spec/ruby/core/integer/bit_xor_spec.rb b/spec/ruby/core/integer/bit_xor_spec.rb index 65f88341e0..ac8826a52f 100644 --- a/spec/ruby/core/integer/bit_xor_spec.rb +++ b/spec/ruby/core/integer/bit_xor_spec.rb @@ -13,14 +13,14 @@ describe "Integer#^" do end it "raises a TypeError when passed a Float" do - lambda { (3 ^ 3.4) }.should raise_error(TypeError) + -> { (3 ^ 3.4) }.should raise_error(TypeError) end it "raises a TypeError and does not call #to_int when defined on an object" do obj = mock("integer bit xor") obj.should_not_receive(:to_int) - lambda { 3 ^ obj }.should raise_error(TypeError) + -> { 3 ^ obj }.should raise_error(TypeError) end end @@ -55,18 +55,18 @@ describe "Integer#^" do it "raises a TypeError when passed a Float" do not_supported_on :opal do - lambda { + -> { bignum_value ^ bignum_value(0xffff).to_f }.should raise_error(TypeError) end - lambda { @bignum ^ 14.5 }.should raise_error(TypeError) + -> { @bignum ^ 14.5 }.should raise_error(TypeError) end it "raises a TypeError and does not call #to_int when defined on an object" do obj = mock("bignum bit xor") obj.should_not_receive(:to_int) - lambda { @bignum ^ obj }.should raise_error(TypeError) + -> { @bignum ^ obj }.should raise_error(TypeError) end end end diff --git a/spec/ruby/core/integer/chr_spec.rb b/spec/ruby/core/integer/chr_spec.rb index 02d0283182..a8755eeb84 100644 --- a/spec/ruby/core/integer/chr_spec.rb +++ b/spec/ruby/core/integer/chr_spec.rb @@ -10,8 +10,8 @@ describe "Integer#chr without argument" do end it "raises a RangeError is self is less than 0" do - lambda { -1.chr }.should raise_error(RangeError) - lambda { -bignum_value.chr }.should raise_error(RangeError) + -> { -1.chr }.should raise_error(RangeError) + -> { -bignum_value.chr }.should raise_error(RangeError) end describe "when Encoding.default_internal is nil" do @@ -44,8 +44,8 @@ describe "Integer#chr without argument" do end it "raises a RangeError is self is greater than 255" do - lambda { 256.chr }.should raise_error(RangeError) - lambda { bignum_value.chr }.should raise_error(RangeError) + -> { 256.chr }.should raise_error(RangeError) + -> { bignum_value.chr }.should raise_error(RangeError) end end @@ -133,7 +133,7 @@ describe "Integer#chr without argument" do [620, "TIS-620"] ].each do |integer, encoding_name| Encoding.default_internal = Encoding.find(encoding_name) - lambda { integer.chr }.should raise_error(RangeError) + -> { integer.chr }.should raise_error(RangeError) end end end @@ -150,7 +150,7 @@ describe "Integer#chr with an encoding argument" do end it "accepts a String as an argument" do - lambda { 0xA4A2.chr('euc-jp') }.should_not raise_error + -> { 0xA4A2.chr('euc-jp') }.should_not raise_error end it "converts a String to an Encoding as Encoding.find does" do @@ -161,12 +161,12 @@ describe "Integer#chr with an encoding argument" do # http://redmine.ruby-lang.org/issues/4869 it "raises a RangeError is self is less than 0" do - lambda { -1.chr(Encoding::UTF_8) }.should raise_error(RangeError) - lambda { -bignum_value.chr(Encoding::EUC_JP) }.should raise_error(RangeError) + -> { -1.chr(Encoding::UTF_8) }.should raise_error(RangeError) + -> { -bignum_value.chr(Encoding::EUC_JP) }.should raise_error(RangeError) end it "raises a RangeError if self is too large" do - lambda { 2206368128.chr(Encoding::UTF_8) }.should raise_error(RangeError) + -> { 2206368128.chr(Encoding::UTF_8) }.should raise_error(RangeError) end it "returns a String with the specified encoding" do @@ -237,7 +237,7 @@ describe "Integer#chr with an encoding argument" do [0xDC00, "UTF-16"], [0xDFFF, "UTF-16"], ].each do |integer, encoding_name| - lambda { integer.chr(encoding_name) }.should raise_error(RangeError) + -> { integer.chr(encoding_name) }.should raise_error(RangeError) end end end diff --git a/spec/ruby/core/integer/coerce_spec.rb b/spec/ruby/core/integer/coerce_spec.rb index 8db15bbaed..9a19baf2ea 100644 --- a/spec/ruby/core/integer/coerce_spec.rb +++ b/spec/ruby/core/integer/coerce_spec.rb @@ -1,5 +1,7 @@ require_relative '../../spec_helper' +require 'bigdecimal' + describe "Integer#coerce" do context "fixnum" do describe "when given a Fixnum" do @@ -11,7 +13,7 @@ describe "Integer#coerce" do describe "when given a String" do it "raises an ArgumentError when trying to coerce with a non-number String" do - lambda { 1.coerce(":)") }.should raise_error(ArgumentError) + -> { 1.coerce(":)") }.should raise_error(ArgumentError) end it "returns an array containing two Floats" do @@ -21,7 +23,7 @@ describe "Integer#coerce" do end it "raises a TypeError when trying to coerce with nil" do - lambda { 1.coerce(nil) }.should raise_error(TypeError) + -> { 1.coerce(nil) }.should raise_error(TypeError) end it "tries to convert the given Object into a Float by using #to_f" do @@ -29,13 +31,13 @@ describe "Integer#coerce" do 2.coerce(obj).should == [1.0, 2.0] (obj = mock('0')).should_receive(:to_f).and_return('0') - lambda { 2.coerce(obj).should == [1.0, 2.0] }.should raise_error(TypeError) + -> { 2.coerce(obj).should == [1.0, 2.0] }.should raise_error(TypeError) end it "raises a TypeError when given an Object that does not respond to #to_f" do - lambda { 1.coerce(mock('x')) }.should raise_error(TypeError) - lambda { 1.coerce(1..4) }.should raise_error(TypeError) - lambda { 1.coerce(:test) }.should raise_error(TypeError) + -> { 1.coerce(mock('x')) }.should raise_error(TypeError) + -> { 1.coerce(1..4) }.should raise_error(TypeError) + -> { 1.coerce(:test) }.should raise_error(TypeError) end end @@ -62,10 +64,10 @@ describe "Integer#coerce" do it "raises a TypeError when not passed a Fixnum or Bignum" do a = bignum_value - lambda { a.coerce(nil) }.should raise_error(TypeError) - lambda { a.coerce(mock('str')) }.should raise_error(TypeError) - lambda { a.coerce(1..4) }.should raise_error(TypeError) - lambda { a.coerce(:test) }.should raise_error(TypeError) + -> { a.coerce(nil) }.should raise_error(TypeError) + -> { a.coerce(mock('str')) }.should raise_error(TypeError) + -> { a.coerce(1..4) }.should raise_error(TypeError) + -> { a.coerce(:test) }.should raise_error(TypeError) end it "coerces both values to Floats and returns [other, self] when passed a Float" do @@ -88,4 +90,15 @@ describe "Integer#coerce" do ary.should == [1.2, a.to_f] end end + + context "bigdecimal" do + it "produces Floats" do + x, y = 3.coerce(BigDecimal("3.4")) + x.class.should == Float + x.should == 3.4 + y.class.should == Float + y.should == 3.0 + end + end + end diff --git a/spec/ruby/core/integer/comparison_spec.rb b/spec/ruby/core/integer/comparison_spec.rb index 4cf1d7cdc7..762af51535 100644 --- a/spec/ruby/core/integer/comparison_spec.rb +++ b/spec/ruby/core/integer/comparison_spec.rb @@ -127,7 +127,7 @@ describe "Integer#<=>" do ruby_version_is ""..."2.5" do it "returns nil if #coerce raises an exception" do @num.should_receive(:coerce).with(@big).and_raise(RuntimeError) - lambda { + -> { @result = (@big <=> @num) }.should complain(/Numerical comparison operators will no more rescue exceptions/) @result.should be_nil @@ -137,7 +137,7 @@ describe "Integer#<=>" do ruby_version_is "2.5" do it "lets the exception go through if #coerce raises an exception" do @num.should_receive(:coerce).with(@big).and_raise(RuntimeError.new("my error")) - lambda { + -> { @big <=> @num }.should raise_error(RuntimeError, "my error") end @@ -145,7 +145,7 @@ describe "Integer#<=>" do it "raises an exception if #coerce raises a non-StandardError exception" do @num.should_receive(:coerce).with(@big).and_raise(Exception) - lambda { @big <=> @num }.should raise_error(Exception) + -> { @big <=> @num }.should raise_error(Exception) end it "returns nil if #coerce does not return an Array" do diff --git a/spec/ruby/core/integer/digits_spec.rb b/spec/ruby/core/integer/digits_spec.rb index 85afb6f50f..4a8e33980c 100644 --- a/spec/ruby/core/integer/digits_spec.rb +++ b/spec/ruby/core/integer/digits_spec.rb @@ -19,14 +19,14 @@ describe "Integer#digits" do end it "raises ArgumentError when calling with a radix less than 2" do - lambda { 12345.digits(1) }.should raise_error(ArgumentError) + -> { 12345.digits(1) }.should raise_error(ArgumentError) end it "raises ArgumentError when calling with a negative radix" do - lambda { 12345.digits(-2) }.should raise_error(ArgumentError) + -> { 12345.digits(-2) }.should raise_error(ArgumentError) end it "raises Math::DomainError when calling digits on a negative number" do - lambda { -12345.digits(7) }.should raise_error(Math::DomainError) + -> { -12345.digits(7) }.should raise_error(Math::DomainError) end end diff --git a/spec/ruby/core/integer/div_spec.rb b/spec/ruby/core/integer/div_spec.rb index ca69ff4681..087d012fe0 100644 --- a/spec/ruby/core/integer/div_spec.rb +++ b/spec/ruby/core/integer/div_spec.rb @@ -46,21 +46,21 @@ describe "Integer#div" do end it "raises a ZeroDivisionError when the given argument is 0 and a Float" do - lambda { 0.div(0.0) }.should raise_error(ZeroDivisionError) - lambda { 10.div(0.0) }.should raise_error(ZeroDivisionError) - lambda { -10.div(0.0) }.should raise_error(ZeroDivisionError) + -> { 0.div(0.0) }.should raise_error(ZeroDivisionError) + -> { 10.div(0.0) }.should raise_error(ZeroDivisionError) + -> { -10.div(0.0) }.should raise_error(ZeroDivisionError) end it "raises a ZeroDivisionError when the given argument is 0 and not a Float" do - lambda { 13.div(0) }.should raise_error(ZeroDivisionError) - lambda { 13.div(-0) }.should raise_error(ZeroDivisionError) + -> { 13.div(0) }.should raise_error(ZeroDivisionError) + -> { 13.div(-0) }.should raise_error(ZeroDivisionError) end it "raises a TypeError when given a non-numeric argument" do - lambda { 13.div(mock('10')) }.should raise_error(TypeError) - lambda { 5.div("2") }.should raise_error(TypeError) - lambda { 5.div(:"2") }.should raise_error(TypeError) - lambda { 5.div([]) }.should raise_error(TypeError) + -> { 13.div(mock('10')) }.should raise_error(TypeError) + -> { 5.div("2") }.should raise_error(TypeError) + -> { 5.div(:"2") }.should raise_error(TypeError) + -> { 5.div([]) }.should raise_error(TypeError) end end @@ -118,9 +118,9 @@ describe "Integer#div" do end it "raises a TypeError when given a non-numeric" do - lambda { @bignum.div(mock("10")) }.should raise_error(TypeError) - lambda { @bignum.div("2") }.should raise_error(TypeError) - lambda { @bignum.div(:symbol) }.should raise_error(TypeError) + -> { @bignum.div(mock("10")) }.should raise_error(TypeError) + -> { @bignum.div("2") }.should raise_error(TypeError) + -> { @bignum.div(:symbol) }.should raise_error(TypeError) end it "returns a result of integer division of self by a float argument" do @@ -134,13 +134,13 @@ describe "Integer#div" do # #5490 it "raises ZeroDivisionError if the argument is 0 and is a Float" do - lambda { @bignum.div(0.0) }.should raise_error(ZeroDivisionError) - lambda { @bignum.div(-0.0) }.should raise_error(ZeroDivisionError) + -> { @bignum.div(0.0) }.should raise_error(ZeroDivisionError) + -> { @bignum.div(-0.0) }.should raise_error(ZeroDivisionError) end it "raises ZeroDivisionError if the argument is 0 and is not a Float" do - lambda { @bignum.div(0) }.should raise_error(ZeroDivisionError) - lambda { @bignum.div(-0) }.should raise_error(ZeroDivisionError) + -> { @bignum.div(0) }.should raise_error(ZeroDivisionError) + -> { @bignum.div(-0) }.should raise_error(ZeroDivisionError) end end end diff --git a/spec/ruby/core/integer/divide_spec.rb b/spec/ruby/core/integer/divide_spec.rb index 2d49307628..a32d68c229 100644 --- a/spec/ruby/core/integer/divide_spec.rb +++ b/spec/ruby/core/integer/divide_spec.rb @@ -27,7 +27,7 @@ describe "Integer#/" do end it "raises a ZeroDivisionError if the given argument is zero and not a Float" do - lambda { 1 / 0 }.should raise_error(ZeroDivisionError) + -> { 1 / 0 }.should raise_error(ZeroDivisionError) end it "does NOT raise ZeroDivisionError if the given argument is zero and is a Float" do @@ -41,9 +41,9 @@ describe "Integer#/" do end it "raises a TypeError when given a non-Integer" do - lambda { 13 / mock('10') }.should raise_error(TypeError) - lambda { 13 / "10" }.should raise_error(TypeError) - lambda { 13 / :symbol }.should raise_error(TypeError) + -> { 13 / mock('10') }.should raise_error(TypeError) + -> { 13 / "10" }.should raise_error(TypeError) + -> { 13 / :symbol }.should raise_error(TypeError) end end @@ -83,13 +83,13 @@ describe "Integer#/" do end it "raises a ZeroDivisionError if other is zero and not a Float" do - lambda { @bignum / 0 }.should raise_error(ZeroDivisionError) + -> { @bignum / 0 }.should raise_error(ZeroDivisionError) end it "raises a TypeError when given a non-numeric" do - lambda { @bignum / mock('10') }.should raise_error(TypeError) - lambda { @bignum / "2" }.should raise_error(TypeError) - lambda { @bignum / :symbol }.should raise_error(TypeError) + -> { @bignum / mock('10') }.should raise_error(TypeError) + -> { @bignum / "2" }.should raise_error(TypeError) + -> { @bignum / :symbol }.should raise_error(TypeError) end end end diff --git a/spec/ruby/core/integer/divmod_spec.rb b/spec/ruby/core/integer/divmod_spec.rb index 27fb34574c..d88925caad 100644 --- a/spec/ruby/core/integer/divmod_spec.rb +++ b/spec/ruby/core/integer/divmod_spec.rb @@ -14,24 +14,24 @@ describe "Integer#divmod" do end it "raises a ZeroDivisionError when the given argument is 0" do - lambda { 13.divmod(0) }.should raise_error(ZeroDivisionError) - lambda { 0.divmod(0) }.should raise_error(ZeroDivisionError) - lambda { -10.divmod(0) }.should raise_error(ZeroDivisionError) + -> { 13.divmod(0) }.should raise_error(ZeroDivisionError) + -> { 0.divmod(0) }.should raise_error(ZeroDivisionError) + -> { -10.divmod(0) }.should raise_error(ZeroDivisionError) end it "raises a ZeroDivisionError when the given argument is 0 and a Float" do - lambda { 0.divmod(0.0) }.should raise_error(ZeroDivisionError) - lambda { 10.divmod(0.0) }.should raise_error(ZeroDivisionError) - lambda { -10.divmod(0.0) }.should raise_error(ZeroDivisionError) + -> { 0.divmod(0.0) }.should raise_error(ZeroDivisionError) + -> { 10.divmod(0.0) }.should raise_error(ZeroDivisionError) + -> { -10.divmod(0.0) }.should raise_error(ZeroDivisionError) end it "raises a TypeError when given a non-Integer" do - lambda { + -> { (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10) 13.divmod(obj) }.should raise_error(TypeError) - lambda { 13.divmod("10") }.should raise_error(TypeError) - lambda { 13.divmod(:symbol) }.should raise_error(TypeError) + -> { 13.divmod("10") }.should raise_error(TypeError) + -> { 13.divmod(:symbol) }.should raise_error(TypeError) end end @@ -94,24 +94,24 @@ describe "Integer#divmod" do end it "raises a ZeroDivisionError when the given argument is 0" do - lambda { @bignum.divmod(0) }.should raise_error(ZeroDivisionError) - lambda { (-@bignum).divmod(0) }.should raise_error(ZeroDivisionError) + -> { @bignum.divmod(0) }.should raise_error(ZeroDivisionError) + -> { (-@bignum).divmod(0) }.should raise_error(ZeroDivisionError) end # Behaviour established as correct in r23953 it "raises a FloatDomainError if other is NaN" do - lambda { @bignum.divmod(nan_value) }.should raise_error(FloatDomainError) + -> { @bignum.divmod(nan_value) }.should raise_error(FloatDomainError) end it "raises a ZeroDivisionError when the given argument is 0 and a Float" do - lambda { @bignum.divmod(0.0) }.should raise_error(ZeroDivisionError) - lambda { (-@bignum).divmod(0.0) }.should raise_error(ZeroDivisionError) + -> { @bignum.divmod(0.0) }.should raise_error(ZeroDivisionError) + -> { (-@bignum).divmod(0.0) }.should raise_error(ZeroDivisionError) end it "raises a TypeError when the given argument is not an Integer" do - lambda { @bignum.divmod(mock('10')) }.should raise_error(TypeError) - lambda { @bignum.divmod("10") }.should raise_error(TypeError) - lambda { @bignum.divmod(:symbol) }.should raise_error(TypeError) + -> { @bignum.divmod(mock('10')) }.should raise_error(TypeError) + -> { @bignum.divmod("10") }.should raise_error(TypeError) + -> { @bignum.divmod(:symbol) }.should raise_error(TypeError) end end end diff --git a/spec/ruby/core/integer/downto_spec.rb b/spec/ruby/core/integer/downto_spec.rb index 92dee89fc9..af7a7e36b9 100644 --- a/spec/ruby/core/integer/downto_spec.rb +++ b/spec/ruby/core/integer/downto_spec.rb @@ -27,8 +27,8 @@ describe "Integer#downto [stop] when self and stop are Fixnums" do end it "raises an ArgumentError for invalid endpoints" do - lambda {1.downto("A") {|x| p x } }.should raise_error(ArgumentError) - lambda {1.downto(nil) {|x| p x } }.should raise_error(ArgumentError) + -> {1.downto("A") {|x| p x } }.should raise_error(ArgumentError) + -> {1.downto(nil) {|x| p x } }.should raise_error(ArgumentError) end describe "when no block is given" do @@ -45,9 +45,9 @@ describe "Integer#downto [stop] when self and stop are Fixnums" do describe "size" do it "raises an ArgumentError for invalid endpoints" do enum = 1.downto("A") - lambda { enum.size }.should raise_error(ArgumentError) + -> { enum.size }.should raise_error(ArgumentError) enum = 1.downto(nil) - lambda { enum.size }.should raise_error(ArgumentError) + -> { enum.size }.should raise_error(ArgumentError) end it "returns self - stop + 1" do diff --git a/spec/ruby/core/integer/element_reference_spec.rb b/spec/ruby/core/integer/element_reference_spec.rb index 6c72a717d6..99283fac34 100644 --- a/spec/ruby/core/integer/element_reference_spec.rb +++ b/spec/ruby/core/integer/element_reference_spec.rb @@ -59,13 +59,13 @@ describe "Integer#[]" do end it "raises a TypeError when passed a String" do - lambda { 3["3"] }.should raise_error(TypeError) + -> { 3["3"] }.should raise_error(TypeError) end it "raises a TypeError when #to_int does not return an Integer" do obj = mock('asdf') obj.should_receive(:to_int).and_return("asdf") - lambda { 3[obj] }.should raise_error(TypeError) + -> { 3[obj] }.should raise_error(TypeError) end it "calls #to_int to coerce a String to a Bignum and returns 0" do @@ -102,10 +102,10 @@ describe "Integer#[]" do it "raises a TypeError when the given argument can't be converted to Integer" do obj = mock('asdf') - lambda { @bignum[obj] }.should raise_error(TypeError) + -> { @bignum[obj] }.should raise_error(TypeError) obj.should_receive(:to_int).and_return("asdf") - lambda { @bignum[obj] }.should raise_error(TypeError) + -> { @bignum[obj] }.should raise_error(TypeError) end end end diff --git a/spec/ruby/core/integer/fdiv_spec.rb b/spec/ruby/core/integer/fdiv_spec.rb index b27e6f1389..6de170278f 100644 --- a/spec/ruby/core/integer/fdiv_spec.rb +++ b/spec/ruby/core/integer/fdiv_spec.rb @@ -35,11 +35,11 @@ describe "Integer#fdiv" do end it "raises a TypeError when argument isn't numeric" do - lambda { 1.fdiv(mock('non-numeric')) }.should raise_error(TypeError) + -> { 1.fdiv(mock('non-numeric')) }.should raise_error(TypeError) end it "raises an ArgumentError when passed multiple arguments" do - lambda { 1.fdiv(6,0.2) }.should raise_error(ArgumentError) + -> { 1.fdiv(6,0.2) }.should raise_error(ArgumentError) end it "follows the coercion protocol" do diff --git a/spec/ruby/core/integer/gcd_spec.rb b/spec/ruby/core/integer/gcd_spec.rb index 238bf66cc0..8aa654a16a 100644 --- a/spec/ruby/core/integer/gcd_spec.rb +++ b/spec/ruby/core/integer/gcd_spec.rb @@ -55,15 +55,15 @@ describe "Integer#gcd" do end it "raises an ArgumentError if not given an argument" do - lambda { 12.gcd }.should raise_error(ArgumentError) + -> { 12.gcd }.should raise_error(ArgumentError) end it "raises an ArgumentError if given more than one argument" do - lambda { 12.gcd(30, 20) }.should raise_error(ArgumentError) + -> { 12.gcd(30, 20) }.should raise_error(ArgumentError) end it "raises a TypeError unless the argument is an Integer" do - lambda { 39.gcd(3.8) }.should raise_error(TypeError) - lambda { 45872.gcd([]) }.should raise_error(TypeError) + -> { 39.gcd(3.8) }.should raise_error(TypeError) + -> { 45872.gcd([]) }.should raise_error(TypeError) end end diff --git a/spec/ruby/core/integer/gcdlcm_spec.rb b/spec/ruby/core/integer/gcdlcm_spec.rb index 362f8a51bd..5b3669e62a 100644 --- a/spec/ruby/core/integer/gcdlcm_spec.rb +++ b/spec/ruby/core/integer/gcdlcm_spec.rb @@ -39,15 +39,15 @@ describe "Integer#gcdlcm" do end it "raises an ArgumentError if not given an argument" do - lambda { 12.gcdlcm }.should raise_error(ArgumentError) + -> { 12.gcdlcm }.should raise_error(ArgumentError) end it "raises an ArgumentError if given more than one argument" do - lambda { 12.gcdlcm(30, 20) }.should raise_error(ArgumentError) + -> { 12.gcdlcm(30, 20) }.should raise_error(ArgumentError) end it "raises a TypeError unless the argument is an Integer" do - lambda { 39.gcdlcm(3.8) }.should raise_error(TypeError) - lambda { 45872.gcdlcm([]) }.should raise_error(TypeError) + -> { 39.gcdlcm(3.8) }.should raise_error(TypeError) + -> { 45872.gcdlcm([]) }.should raise_error(TypeError) end end diff --git a/spec/ruby/core/integer/gt_spec.rb b/spec/ruby/core/integer/gt_spec.rb index 14c51c9acc..428a6f6888 100644 --- a/spec/ruby/core/integer/gt_spec.rb +++ b/spec/ruby/core/integer/gt_spec.rb @@ -23,8 +23,8 @@ describe "Integer#>" do end it "raises an ArgumentError when given a non-Integer" do - lambda { 5 > "4" }.should raise_error(ArgumentError) - lambda { 5 > mock('x') }.should raise_error(ArgumentError) + -> { 5 > "4" }.should raise_error(ArgumentError) + -> { 5 > mock('x') }.should raise_error(ArgumentError) end end @@ -42,8 +42,8 @@ describe "Integer#>" do end it "raises an ArgumentError when given a non-Integer" do - lambda { @bignum > "4" }.should raise_error(ArgumentError) - lambda { @bignum > mock('str') }.should raise_error(ArgumentError) + -> { @bignum > "4" }.should raise_error(ArgumentError) + -> { @bignum > mock('str') }.should raise_error(ArgumentError) end end end diff --git a/spec/ruby/core/integer/gte_spec.rb b/spec/ruby/core/integer/gte_spec.rb index 3d5c48faa5..ce1385c360 100644 --- a/spec/ruby/core/integer/gte_spec.rb +++ b/spec/ruby/core/integer/gte_spec.rb @@ -24,8 +24,8 @@ describe "Integer#>=" do end it "raises an ArgumentError when given a non-Integer" do - lambda { 5 >= "4" }.should raise_error(ArgumentError) - lambda { 5 >= mock('x') }.should raise_error(ArgumentError) + -> { 5 >= "4" }.should raise_error(ArgumentError) + -> { 5 >= mock('x') }.should raise_error(ArgumentError) end end @@ -42,8 +42,8 @@ describe "Integer#>=" do end it "raises an ArgumentError when given a non-Integer" do - lambda { @bignum >= "4" }.should raise_error(ArgumentError) - lambda { @bignum >= mock('str') }.should raise_error(ArgumentError) + -> { @bignum >= "4" }.should raise_error(ArgumentError) + -> { @bignum >= mock('str') }.should raise_error(ArgumentError) end end end diff --git a/spec/ruby/core/integer/lcm_spec.rb b/spec/ruby/core/integer/lcm_spec.rb index 6d608bdf41..77d3ad3488 100644 --- a/spec/ruby/core/integer/lcm_spec.rb +++ b/spec/ruby/core/integer/lcm_spec.rb @@ -44,15 +44,15 @@ describe "Integer#lcm" do end it "raises an ArgumentError if not given an argument" do - lambda { 12.lcm }.should raise_error(ArgumentError) + -> { 12.lcm }.should raise_error(ArgumentError) end it "raises an ArgumentError if given more than one argument" do - lambda { 12.lcm(30, 20) }.should raise_error(ArgumentError) + -> { 12.lcm(30, 20) }.should raise_error(ArgumentError) end it "raises a TypeError unless the argument is an Integer" do - lambda { 39.lcm(3.8) }.should raise_error(TypeError) - lambda { 45872.lcm([]) }.should raise_error(TypeError) + -> { 39.lcm(3.8) }.should raise_error(TypeError) + -> { 45872.lcm([]) }.should raise_error(TypeError) end end diff --git a/spec/ruby/core/integer/left_shift_spec.rb b/spec/ruby/core/integer/left_shift_spec.rb index a240c541c5..4b5ef9386e 100644 --- a/spec/ruby/core/integer/left_shift_spec.rb +++ b/spec/ruby/core/integer/left_shift_spec.rb @@ -79,15 +79,15 @@ describe "Integer#<< (with n << m)" do obj = mock("a string") obj.should_receive(:to_int).and_return("asdf") - lambda { 3 << obj }.should raise_error(TypeError) + -> { 3 << obj }.should raise_error(TypeError) end it "raises a TypeError when passed nil" do - lambda { 3 << nil }.should raise_error(TypeError) + -> { 3 << nil }.should raise_error(TypeError) end it "raises a TypeError when passed a String" do - lambda { 3 << "4" }.should raise_error(TypeError) + -> { 3 << "4" }.should raise_error(TypeError) end end @@ -151,15 +151,15 @@ describe "Integer#<< (with n << m)" do obj = mock("a string") obj.should_receive(:to_int).and_return("asdf") - lambda { @bignum << obj }.should raise_error(TypeError) + -> { @bignum << obj }.should raise_error(TypeError) end it "raises a TypeError when passed nil" do - lambda { @bignum << nil }.should raise_error(TypeError) + -> { @bignum << nil }.should raise_error(TypeError) end it "raises a TypeError when passed a String" do - lambda { @bignum << "4" }.should raise_error(TypeError) + -> { @bignum << "4" }.should raise_error(TypeError) end end end diff --git a/spec/ruby/core/integer/lt_spec.rb b/spec/ruby/core/integer/lt_spec.rb index a33a297d8b..dfe2d9e369 100644 --- a/spec/ruby/core/integer/lt_spec.rb +++ b/spec/ruby/core/integer/lt_spec.rb @@ -23,8 +23,8 @@ describe "Integer#<" do end it "raises an ArgumentError when given a non-Integer" do - lambda { 5 < "4" }.should raise_error(ArgumentError) - lambda { 5 < mock('x') }.should raise_error(ArgumentError) + -> { 5 < "4" }.should raise_error(ArgumentError) + -> { 5 < mock('x') }.should raise_error(ArgumentError) end end @@ -44,8 +44,8 @@ describe "Integer#<" do end it "raises an ArgumentError when given a non-Integer" do - lambda { @bignum < "4" }.should raise_error(ArgumentError) - lambda { @bignum < mock('str') }.should raise_error(ArgumentError) + -> { @bignum < "4" }.should raise_error(ArgumentError) + -> { @bignum < mock('str') }.should raise_error(ArgumentError) end end end diff --git a/spec/ruby/core/integer/lte_spec.rb b/spec/ruby/core/integer/lte_spec.rb index 1d3ecea2ac..3d843a5dd9 100644 --- a/spec/ruby/core/integer/lte_spec.rb +++ b/spec/ruby/core/integer/lte_spec.rb @@ -24,8 +24,8 @@ describe "Integer#<=" do end it "raises an ArgumentError when given a non-Integer" do - lambda { 5 <= "4" }.should raise_error(ArgumentError) - lambda { 5 <= mock('x') }.should raise_error(ArgumentError) + -> { 5 <= "4" }.should raise_error(ArgumentError) + -> { 5 <= mock('x') }.should raise_error(ArgumentError) end end @@ -47,8 +47,8 @@ describe "Integer#<=" do end it "raises an ArgumentError when given a non-Integer" do - lambda { @bignum <= "4" }.should raise_error(ArgumentError) - lambda { @bignum <= mock('str') }.should raise_error(ArgumentError) + -> { @bignum <= "4" }.should raise_error(ArgumentError) + -> { @bignum <= mock('str') }.should raise_error(ArgumentError) end end end diff --git a/spec/ruby/core/integer/minus_spec.rb b/spec/ruby/core/integer/minus_spec.rb index 84db427172..34dd36c1a7 100644 --- a/spec/ruby/core/integer/minus_spec.rb +++ b/spec/ruby/core/integer/minus_spec.rb @@ -20,12 +20,12 @@ describe "Integer#-" do end it "raises a TypeError when given a non-Integer" do - lambda { + -> { (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10) 13 - obj }.should raise_error(TypeError) - lambda { 13 - "10" }.should raise_error(TypeError) - lambda { 13 - :symbol }.should raise_error(TypeError) + -> { 13 - "10" }.should raise_error(TypeError) + -> { 13 - :symbol }.should raise_error(TypeError) end end @@ -41,9 +41,9 @@ describe "Integer#-" do end it "raises a TypeError when given a non-Integer" do - lambda { @bignum - mock('10') }.should raise_error(TypeError) - lambda { @bignum - "10" }.should raise_error(TypeError) - lambda { @bignum - :symbol }.should raise_error(TypeError) + -> { @bignum - mock('10') }.should raise_error(TypeError) + -> { @bignum - "10" }.should raise_error(TypeError) + -> { @bignum - :symbol }.should raise_error(TypeError) end end end diff --git a/spec/ruby/core/integer/multiply_spec.rb b/spec/ruby/core/integer/multiply_spec.rb index 1683b0c96e..919786cbcc 100644 --- a/spec/ruby/core/integer/multiply_spec.rb +++ b/spec/ruby/core/integer/multiply_spec.rb @@ -21,12 +21,12 @@ describe "Integer#*" do end it "raises a TypeError when given a non-Integer" do - lambda { + -> { (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10) 13 * obj }.should raise_error(TypeError) - lambda { 13 * "10" }.should raise_error(TypeError) - lambda { 13 * :symbol }.should raise_error(TypeError) + -> { 13 * "10" }.should raise_error(TypeError) + -> { 13 * :symbol }.should raise_error(TypeError) end end @@ -43,9 +43,9 @@ describe "Integer#*" do end it "raises a TypeError when given a non-Integer" do - lambda { @bignum * mock('10') }.should raise_error(TypeError) - lambda { @bignum * "10" }.should raise_error(TypeError) - lambda { @bignum * :symbol }.should raise_error(TypeError) + -> { @bignum * mock('10') }.should raise_error(TypeError) + -> { @bignum * "10" }.should raise_error(TypeError) + -> { @bignum * :symbol }.should raise_error(TypeError) end end end diff --git a/spec/ruby/core/integer/nobits_spec.rb b/spec/ruby/core/integer/nobits_spec.rb index da689de5df..af3b9e7db0 100644 --- a/spec/ruby/core/integer/nobits_spec.rb +++ b/spec/ruby/core/integer/nobits_spec.rb @@ -27,12 +27,12 @@ ruby_version_is '2.5' do end it "raises a TypeError when given a non-Integer" do - lambda { + -> { (obj = mock('10')).should_receive(:coerce).any_number_of_times.and_return([42,10]) 13.nobits?(obj) }.should raise_error(TypeError) - lambda { 13.nobits?("10") }.should raise_error(TypeError) - lambda { 13.nobits?(:symbol) }.should raise_error(TypeError) + -> { 13.nobits?("10") }.should raise_error(TypeError) + -> { 13.nobits?(:symbol) }.should raise_error(TypeError) end end end diff --git a/spec/ruby/core/integer/plus_spec.rb b/spec/ruby/core/integer/plus_spec.rb index 2880840bc1..7e919a16db 100644 --- a/spec/ruby/core/integer/plus_spec.rb +++ b/spec/ruby/core/integer/plus_spec.rb @@ -20,12 +20,12 @@ describe "Integer#+" do end it "raises a TypeError when given a non-Integer" do - lambda { + -> { (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10) 13 + obj }.should raise_error(TypeError) - lambda { 13 + "10" }.should raise_error(TypeError) - lambda { 13 + :symbol }.should raise_error(TypeError) + -> { 13 + "10" }.should raise_error(TypeError) + -> { 13 + :symbol }.should raise_error(TypeError) end end @@ -41,9 +41,9 @@ describe "Integer#+" do end it "raises a TypeError when given a non-Integer" do - lambda { @bignum + mock('10') }.should raise_error(TypeError) - lambda { @bignum + "10" }.should raise_error(TypeError) - lambda { @bignum + :symbol}.should raise_error(TypeError) + -> { @bignum + mock('10') }.should raise_error(TypeError) + -> { @bignum + "10" }.should raise_error(TypeError) + -> { @bignum + :symbol}.should raise_error(TypeError) end end end diff --git a/spec/ruby/core/integer/rationalize_spec.rb b/spec/ruby/core/integer/rationalize_spec.rb index 590ab40cb2..09d741af33 100644 --- a/spec/ruby/core/integer/rationalize_spec.rb +++ b/spec/ruby/core/integer/rationalize_spec.rb @@ -33,7 +33,7 @@ describe "Integer#rationalize" do end it "raises ArgumentError when passed more than one argument" do - lambda { 1.rationalize(0.1, 0.1) }.should raise_error(ArgumentError) - lambda { 1.rationalize(0.1, 0.1, 2) }.should raise_error(ArgumentError) + -> { 1.rationalize(0.1, 0.1) }.should raise_error(ArgumentError) + -> { 1.rationalize(0.1, 0.1, 2) }.should raise_error(ArgumentError) end end diff --git a/spec/ruby/core/integer/remainder_spec.rb b/spec/ruby/core/integer/remainder_spec.rb index 473c59a2f0..cd10dad6f2 100644 --- a/spec/ruby/core/integer/remainder_spec.rb +++ b/spec/ruby/core/integer/remainder_spec.rb @@ -38,14 +38,14 @@ describe "Integer#remainder" do end it "raises a ZeroDivisionError if other is zero and not a Float" do - lambda { bignum_value(66).remainder(0) }.should raise_error(ZeroDivisionError) + -> { bignum_value(66).remainder(0) }.should raise_error(ZeroDivisionError) end it "does raises ZeroDivisionError if other is zero and a Float" do a = bignum_value(7) b = bignum_value(32) - lambda { a.remainder(0.0) }.should raise_error(ZeroDivisionError) - lambda { b.remainder(-0.0) }.should raise_error(ZeroDivisionError) + -> { a.remainder(0.0) }.should raise_error(ZeroDivisionError) + -> { b.remainder(-0.0) }.should raise_error(ZeroDivisionError) end end end diff --git a/spec/ruby/core/integer/right_shift_spec.rb b/spec/ruby/core/integer/right_shift_spec.rb index 641d4da662..3eeaf3eb2f 100644 --- a/spec/ruby/core/integer/right_shift_spec.rb +++ b/spec/ruby/core/integer/right_shift_spec.rb @@ -79,15 +79,15 @@ describe "Integer#>> (with n >> m)" do obj = mock("a string") obj.should_receive(:to_int).and_return("asdf") - lambda { 3 >> obj }.should raise_error(TypeError) + -> { 3 >> obj }.should raise_error(TypeError) end it "raises a TypeError when passed nil" do - lambda { 3 >> nil }.should raise_error(TypeError) + -> { 3 >> nil }.should raise_error(TypeError) end it "raises a TypeError when passed a String" do - lambda { 3 >> "4" }.should raise_error(TypeError) + -> { 3 >> "4" }.should raise_error(TypeError) end end @@ -177,15 +177,15 @@ describe "Integer#>> (with n >> m)" do obj = mock("a string") obj.should_receive(:to_int).and_return("asdf") - lambda { @bignum >> obj }.should raise_error(TypeError) + -> { @bignum >> obj }.should raise_error(TypeError) end it "raises a TypeError when passed nil" do - lambda { @bignum >> nil }.should raise_error(TypeError) + -> { @bignum >> nil }.should raise_error(TypeError) end it "raises a TypeError when passed a String" do - lambda { @bignum >> "4" }.should raise_error(TypeError) + -> { @bignum >> "4" }.should raise_error(TypeError) end end end diff --git a/spec/ruby/core/integer/round_spec.rb b/spec/ruby/core/integer/round_spec.rb index a45a7b5fb3..feb6d475d3 100644 --- a/spec/ruby/core/integer/round_spec.rb +++ b/spec/ruby/core/integer/round_spec.rb @@ -31,24 +31,24 @@ describe "Integer#round" do platform_is_not wordsize: 32 do it "raises a RangeError when passed a big negative value" do - lambda { 42.round(fixnum_min) }.should raise_error(RangeError) + -> { 42.round(fixnum_min) }.should raise_error(RangeError) end end it "raises a RangeError when passed Float::INFINITY" do - lambda { 42.round(Float::INFINITY) }.should raise_error(RangeError) + -> { 42.round(Float::INFINITY) }.should raise_error(RangeError) end it "raises a RangeError when passed a beyond signed int" do - lambda { 42.round(1<<31) }.should raise_error(RangeError) + -> { 42.round(1<<31) }.should raise_error(RangeError) end it "raises a TypeError when passed a String" do - lambda { 42.round("4") }.should raise_error(TypeError) + -> { 42.round("4") }.should raise_error(TypeError) end it "raises a TypeError when its argument cannot be converted to an Integer" do - lambda { 42.round(nil) }.should raise_error(TypeError) + -> { 42.round(nil) }.should raise_error(TypeError) end it "calls #to_int on the argument to convert it to an Integer" do @@ -60,7 +60,7 @@ describe "Integer#round" do it "raises a TypeError when #to_int does not return an Integer" do obj = mock("Object") obj.stub!(:to_int).and_return([]) - lambda { 42.round(obj) }.should raise_error(TypeError) + -> { 42.round(obj) }.should raise_error(TypeError) end it "returns different rounded values depending on the half option" do @@ -95,7 +95,7 @@ describe "Integer#round" do end it "raises ArgumentError for an unknown rounding mode" do - lambda { 42.round(-1, half: :foo) }.should raise_error(ArgumentError, /invalid rounding mode: foo/) - lambda { 42.round(1, half: :foo) }.should raise_error(ArgumentError, /invalid rounding mode: foo/) + -> { 42.round(-1, half: :foo) }.should raise_error(ArgumentError, /invalid rounding mode: foo/) + -> { 42.round(1, half: :foo) }.should raise_error(ArgumentError, /invalid rounding mode: foo/) end end diff --git a/spec/ruby/core/integer/shared/exponent.rb b/spec/ruby/core/integer/shared/exponent.rb index 810e2a7101..f292cc2448 100644 --- a/spec/ruby/core/integer/shared/exponent.rb +++ b/spec/ruby/core/integer/shared/exponent.rb @@ -99,9 +99,9 @@ describe :integer_exponent, shared: true do end it "raises a TypeError when given a non-Integer" do - lambda { @bignum.send(@method, mock('10')) }.should raise_error(TypeError) - lambda { @bignum.send(@method, "10") }.should raise_error(TypeError) - lambda { @bignum.send(@method, :symbol) }.should raise_error(TypeError) + -> { @bignum.send(@method, mock('10')) }.should raise_error(TypeError) + -> { @bignum.send(@method, "10") }.should raise_error(TypeError) + -> { @bignum.send(@method, :symbol) }.should raise_error(TypeError) end it "switch to a Float when the values is too big" do diff --git a/spec/ruby/core/integer/shared/modulo.rb b/spec/ruby/core/integer/shared/modulo.rb index d545a9af55..b06d81e17d 100644 --- a/spec/ruby/core/integer/shared/modulo.rb +++ b/spec/ruby/core/integer/shared/modulo.rb @@ -21,24 +21,24 @@ describe :integer_modulo, shared: true do end it "raises a ZeroDivisionError when the given argument is 0" do - lambda { 13.send(@method, 0) }.should raise_error(ZeroDivisionError) - lambda { 0.send(@method, 0) }.should raise_error(ZeroDivisionError) - lambda { -10.send(@method, 0) }.should raise_error(ZeroDivisionError) + -> { 13.send(@method, 0) }.should raise_error(ZeroDivisionError) + -> { 0.send(@method, 0) }.should raise_error(ZeroDivisionError) + -> { -10.send(@method, 0) }.should raise_error(ZeroDivisionError) end it "raises a ZeroDivisionError when the given argument is 0 and a Float" do - lambda { 0.send(@method, 0.0) }.should raise_error(ZeroDivisionError) - lambda { 10.send(@method, 0.0) }.should raise_error(ZeroDivisionError) - lambda { -10.send(@method, 0.0) }.should raise_error(ZeroDivisionError) + -> { 0.send(@method, 0.0) }.should raise_error(ZeroDivisionError) + -> { 10.send(@method, 0.0) }.should raise_error(ZeroDivisionError) + -> { -10.send(@method, 0.0) }.should raise_error(ZeroDivisionError) end it "raises a TypeError when given a non-Integer" do - lambda { + -> { (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10) 13.send(@method, obj) }.should raise_error(TypeError) - lambda { 13.send(@method, "10") }.should raise_error(TypeError) - lambda { 13.send(@method, :symbol) }.should raise_error(TypeError) + -> { 13.send(@method, "10") }.should raise_error(TypeError) + -> { 13.send(@method, :symbol) }.should raise_error(TypeError) end end @@ -56,19 +56,19 @@ describe :integer_modulo, shared: true do end it "raises a ZeroDivisionError when the given argument is 0" do - lambda { @bignum.send(@method, 0) }.should raise_error(ZeroDivisionError) - lambda { (-@bignum).send(@method, 0) }.should raise_error(ZeroDivisionError) + -> { @bignum.send(@method, 0) }.should raise_error(ZeroDivisionError) + -> { (-@bignum).send(@method, 0) }.should raise_error(ZeroDivisionError) end it "raises a ZeroDivisionError when the given argument is 0 and a Float" do - lambda { @bignum.send(@method, 0.0) }.should raise_error(ZeroDivisionError) - lambda { -@bignum.send(@method, 0.0) }.should raise_error(ZeroDivisionError) + -> { @bignum.send(@method, 0.0) }.should raise_error(ZeroDivisionError) + -> { -@bignum.send(@method, 0.0) }.should raise_error(ZeroDivisionError) end it "raises a TypeError when given a non-Integer" do - lambda { @bignum.send(@method, mock('10')) }.should raise_error(TypeError) - lambda { @bignum.send(@method, "10") }.should raise_error(TypeError) - lambda { @bignum.send(@method, :symbol) }.should raise_error(TypeError) + -> { @bignum.send(@method, mock('10')) }.should raise_error(TypeError) + -> { @bignum.send(@method, "10") }.should raise_error(TypeError) + -> { @bignum.send(@method, :symbol) }.should raise_error(TypeError) end end end diff --git a/spec/ruby/core/integer/sqrt_spec.rb b/spec/ruby/core/integer/sqrt_spec.rb index e40bd12b19..e56da058a0 100644 --- a/spec/ruby/core/integer/sqrt_spec.rb +++ b/spec/ruby/core/integer/sqrt_spec.rb @@ -15,7 +15,7 @@ ruby_version_is "2.5" do end it "raises a Math::DomainError if the argument is negative" do - lambda { Integer.sqrt(-4) }.should raise_error(Math::DomainError) + -> { Integer.sqrt(-4) }.should raise_error(Math::DomainError) end it "accepts any argument that can be coerced to Integer" do @@ -27,7 +27,7 @@ ruby_version_is "2.5" do end it "raises a TypeError if the argument cannot be coerced to Integer" do - lambda { Integer.sqrt("test") }.should raise_error(TypeError) + -> { Integer.sqrt("test") }.should raise_error(TypeError) end end end diff --git a/spec/ruby/core/integer/to_r_spec.rb b/spec/ruby/core/integer/to_r_spec.rb index dbb12166f1..4a40575b7f 100644 --- a/spec/ruby/core/integer/to_r_spec.rb +++ b/spec/ruby/core/integer/to_r_spec.rb @@ -20,7 +20,7 @@ describe "Integer#to_r" do end it "raises an ArgumentError if given any arguments" do - lambda { 287.to_r(2) }.should raise_error(ArgumentError) - lambda { 9102826.to_r(309, [], 71) }.should raise_error(ArgumentError) + -> { 287.to_r(2) }.should raise_error(ArgumentError) + -> { 9102826.to_r(309, [], 71) }.should raise_error(ArgumentError) end end diff --git a/spec/ruby/core/integer/to_s_spec.rb b/spec/ruby/core/integer/to_s_spec.rb index 687dc9d18f..7988bfde7a 100644 --- a/spec/ruby/core/integer/to_s_spec.rb +++ b/spec/ruby/core/integer/to_s_spec.rb @@ -13,10 +13,10 @@ describe "Integer#to_s" do end it "raises an ArgumentError if the base is less than 2 or higher than 36" do - lambda { 123.to_s(-1) }.should raise_error(ArgumentError) - lambda { 123.to_s(0) }.should raise_error(ArgumentError) - lambda { 123.to_s(1) }.should raise_error(ArgumentError) - lambda { 123.to_s(37) }.should raise_error(ArgumentError) + -> { 123.to_s(-1) }.should raise_error(ArgumentError) + -> { 123.to_s(0) }.should raise_error(ArgumentError) + -> { 123.to_s(1) }.should raise_error(ArgumentError) + -> { 123.to_s(37) }.should raise_error(ArgumentError) end end @@ -59,10 +59,10 @@ describe "Integer#to_s" do end it "raises an ArgumentError if the base is less than 2 or higher than 36" do - lambda { 123.to_s(-1) }.should raise_error(ArgumentError) - lambda { 123.to_s(0) }.should raise_error(ArgumentError) - lambda { 123.to_s(1) }.should raise_error(ArgumentError) - lambda { 123.to_s(37) }.should raise_error(ArgumentError) + -> { 123.to_s(-1) }.should raise_error(ArgumentError) + -> { 123.to_s(0) }.should raise_error(ArgumentError) + -> { 123.to_s(1) }.should raise_error(ArgumentError) + -> { 123.to_s(37) }.should raise_error(ArgumentError) end end diff --git a/spec/ruby/core/integer/upto_spec.rb b/spec/ruby/core/integer/upto_spec.rb index 7cab834ad4..6049eb173e 100644 --- a/spec/ruby/core/integer/upto_spec.rb +++ b/spec/ruby/core/integer/upto_spec.rb @@ -27,8 +27,8 @@ describe "Integer#upto [stop] when self and stop are Fixnums" do end it "raises an ArgumentError for non-numeric endpoints" do - lambda { 1.upto("A") {|x| p x} }.should raise_error(ArgumentError) - lambda { 1.upto(nil) {|x| p x} }.should raise_error(ArgumentError) + -> { 1.upto("A") {|x| p x} }.should raise_error(ArgumentError) + -> { 1.upto(nil) {|x| p x} }.should raise_error(ArgumentError) end describe "when no block is given" do @@ -45,9 +45,9 @@ describe "Integer#upto [stop] when self and stop are Fixnums" do describe "size" do it "raises an ArgumentError for non-numeric endpoints" do enum = 1.upto("A") - lambda { enum.size }.should raise_error(ArgumentError) + -> { enum.size }.should raise_error(ArgumentError) enum = 1.upto(nil) - lambda { enum.size }.should raise_error(ArgumentError) + -> { enum.size }.should raise_error(ArgumentError) end it "returns stop - self + 1" do |