diff options
Diffstat (limited to 'spec/ruby/core/integer/lte_spec.rb')
| -rw-r--r-- | spec/ruby/core/integer/lte_spec.rb | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/spec/ruby/core/integer/lte_spec.rb b/spec/ruby/core/integer/lte_spec.rb index 3d843a5dd9..9ef1c9f604 100644 --- a/spec/ruby/core/integer/lte_spec.rb +++ b/spec/ruby/core/integer/lte_spec.rb @@ -2,13 +2,7 @@ require_relative '../../spec_helper' require_relative 'shared/comparison_coerce' describe "Integer#<=" do - ruby_version_is "2.4"..."2.5" do - it_behaves_like :integer_comparison_coerce_rescue, :<= - end - - ruby_version_is "2.5" do - it_behaves_like :integer_comparison_coerce_not_rescue, :<= - end + it_behaves_like :integer_comparison_coerce_not_rescue, :<= context "fixnum" do it "returns true if self is less than or equal to other" do @@ -24,8 +18,8 @@ describe "Integer#<=" do end it "raises an ArgumentError when given a non-Integer" do - -> { 5 <= "4" }.should raise_error(ArgumentError) - -> { 5 <= mock('x') }.should raise_error(ArgumentError) + -> { 5 <= "4" }.should.raise(ArgumentError) + -> { 5 <= mock('x') }.should.raise(ArgumentError) end end @@ -46,9 +40,19 @@ describe "Integer#<=" do (@bignum <= (@bignum + 0.5)).should == false end + it "returns true for bignums compare to a bigger float" do + (18446744073709551616 <= 1.8446744073709552e+19).should == true + (@bignum <= (@bignum + 9999.0)).should == true + end + it "raises an ArgumentError when given a non-Integer" do - -> { @bignum <= "4" }.should raise_error(ArgumentError) - -> { @bignum <= mock('str') }.should raise_error(ArgumentError) + -> { @bignum <= "4" }.should.raise(ArgumentError) + -> { @bignum <= mock('str') }.should.raise(ArgumentError) + end + + it "dispatches the correct operator after coercion" do + (bignum_value <= IntegerSpecs::CoercibleNumeric.new(bignum_value * 2)).should == true + (bignum_value <= IntegerSpecs::CoercibleNumeric.new(1)).should == false end end end |
