diff options
Diffstat (limited to 'spec/ruby/core/integer/comparison_spec.rb')
| -rw-r--r-- | spec/ruby/core/integer/comparison_spec.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/spec/ruby/core/integer/comparison_spec.rb b/spec/ruby/core/integer/comparison_spec.rb index 408c8e52ce..cc5cbe2506 100644 --- a/spec/ruby/core/integer/comparison_spec.rb +++ b/spec/ruby/core/integer/comparison_spec.rb @@ -128,17 +128,17 @@ describe "Integer#<=>" do @num.should_receive(:coerce).with(@big).and_raise(RuntimeError.new("my error")) -> { @big <=> @num - }.should raise_error(RuntimeError, "my error") + }.should.raise(RuntimeError, "my error") end it "raises an exception if #coerce raises a non-StandardError exception" do @num.should_receive(:coerce).with(@big).and_raise(Exception) - -> { @big <=> @num }.should raise_error(Exception) + -> { @big <=> @num }.should.raise(Exception) end it "returns nil if #coerce does not return an Array" do @num.should_receive(:coerce).with(@big).and_return(nil) - (@big <=> @num).should be_nil + (@big <=> @num).should == nil end it "returns -1 if the coerced value is larger" do @@ -157,6 +157,14 @@ describe "Integer#<=>" do end end + describe "with a Float" do + it "does not lose precision for values that don't fit in a double" do + (bignum_value(1) <=> bignum_value.to_f).should == 1 + (bignum_value <=> bignum_value.to_f).should == 0 + ((bignum_value - 1) <=> bignum_value.to_f).should == -1 + end + end + # The tests below are taken from matz's revision 23730 for Ruby trunk it "returns 1 when self is Infinity and other is a Bignum" do (infinity_value <=> Float::MAX.to_i*2).should == 1 |
