2018-03-04 15:09:32 +00:00
|
|
|
require_relative '../../spec_helper'
|
|
|
|
require_relative 'shared/comparison_coerce'
|
2017-12-27 16:12:47 +00:00
|
|
|
|
|
|
|
describe "Integer#>" do
|
2020-02-08 19:43:27 +09:00
|
|
|
it_behaves_like :integer_comparison_coerce_not_rescue, :>
|
2018-01-29 16:08:16 +00:00
|
|
|
|
|
|
|
context "fixnum" do
|
|
|
|
it "returns true if self is greater than the given argument" do
|
|
|
|
(13 > 2).should == true
|
|
|
|
(-500 > -600).should == true
|
|
|
|
|
|
|
|
(1 > 5).should == false
|
|
|
|
(5 > 5).should == false
|
|
|
|
|
|
|
|
(900 > bignum_value).should == false
|
|
|
|
(5 > 4.999).should == true
|
|
|
|
end
|
|
|
|
|
|
|
|
it "raises an ArgumentError when given a non-Integer" do
|
2019-07-27 12:40:09 +02:00
|
|
|
-> { 5 > "4" }.should raise_error(ArgumentError)
|
|
|
|
-> { 5 > mock('x') }.should raise_error(ArgumentError)
|
2018-01-29 16:08:16 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "bignum" do
|
|
|
|
before :each do
|
|
|
|
@bignum = bignum_value(732)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns true if self is greater than the given argument" do
|
|
|
|
(@bignum > (@bignum - 1)).should == true
|
|
|
|
(@bignum > 14.6).should == true
|
|
|
|
(@bignum > 10).should == true
|
|
|
|
|
|
|
|
(@bignum > (@bignum + 500)).should == false
|
|
|
|
end
|
|
|
|
|
|
|
|
it "raises an ArgumentError when given a non-Integer" do
|
2019-07-27 12:40:09 +02:00
|
|
|
-> { @bignum > "4" }.should raise_error(ArgumentError)
|
|
|
|
-> { @bignum > mock('str') }.should raise_error(ArgumentError)
|
2018-01-29 16:08:16 +00:00
|
|
|
end
|
|
|
|
end
|
2017-12-27 16:12:47 +00:00
|
|
|
end
|