diff options
Diffstat (limited to 'spec/ruby/core/integer')
| -rw-r--r-- | spec/ruby/core/integer/ceil_spec.rb | 11 | ||||
| -rw-r--r-- | spec/ruby/core/integer/shared/integer_ceil_precision.rb | 25 | ||||
| -rw-r--r-- | spec/ruby/core/integer/shared/integer_floor_precision.rb | 9 |
3 files changed, 22 insertions, 23 deletions
diff --git a/spec/ruby/core/integer/ceil_spec.rb b/spec/ruby/core/integer/ceil_spec.rb index eb633fba78..395be58fbd 100644 --- a/spec/ruby/core/integer/ceil_spec.rb +++ b/spec/ruby/core/integer/ceil_spec.rb @@ -10,15 +10,4 @@ describe "Integer#ceil" do context "with precision" do it_behaves_like :integer_ceil_precision, :Integer end - - context "precision argument specified as part of the ceil method is negative" do - it "returns the smallest integer greater than self with at least precision.abs trailing zeros" do - 18.ceil(-1).should eql(20) - 18.ceil(-2).should eql(100) - 18.ceil(-3).should eql(1000) - -1832.ceil(-1).should eql(-1830) - -1832.ceil(-2).should eql(-1800) - -1832.ceil(-3).should eql(-1000) - end - end end diff --git a/spec/ruby/core/integer/shared/integer_ceil_precision.rb b/spec/ruby/core/integer/shared/integer_ceil_precision.rb index 9f31c2cf61..b23c17937f 100644 --- a/spec/ruby/core/integer/shared/integer_ceil_precision.rb +++ b/spec/ruby/core/integer/shared/integer_ceil_precision.rb @@ -1,6 +1,6 @@ describe :integer_ceil_precision, shared: true do context "precision is zero" do - it "returns integer self" do + it "returns Integer equal to self" do send(@method, 0).ceil(0).should.eql?(0) send(@method, 123).ceil(0).should.eql?(123) send(@method, -123).ceil(0).should.eql?(-123) @@ -23,7 +23,16 @@ describe :integer_ceil_precision, shared: true do send(@method, 0).ceil(-10).should.eql?(0) end - it "returns largest integer less than self with at least precision.abs trailing zeros" do + it "returns Integer equal to self if there are already at least precision.abs trailing zeros" do + send(@method, 10).ceil(-1).should.eql?(10) + send(@method, 100).ceil(-1).should.eql?(100) + send(@method, 100).ceil(-2).should.eql?(100) + send(@method, -10).ceil(-1).should.eql?(-10) + send(@method, -100).ceil(-1).should.eql?(-100) + send(@method, -100).ceil(-2).should.eql?(-100) + end + + it "returns smallest Integer greater than self with at least precision.abs trailing zeros" do send(@method, 123).ceil(-1).should.eql?(130) send(@method, 123).ceil(-2).should.eql?(200) send(@method, 123).ceil(-3).should.eql?(1000) @@ -31,13 +40,15 @@ describe :integer_ceil_precision, shared: true do send(@method, -123).ceil(-1).should.eql?(-120) send(@method, -123).ceil(-2).should.eql?(-100) send(@method, -123).ceil(-3).should.eql?(0) + + send(@method, 100).ceil(-3).should.eql?(1000) + send(@method, -100).ceil(-3).should.eql?(0) end - ruby_bug "#20654", ""..."3.4" do - it "returns 10**precision.abs when precision.abs is larger than the number digits of self" do - send(@method, 123).ceil(-20).should.eql?(100000000000000000000) - send(@method, 123).ceil(-50).should.eql?(100000000000000000000000000000000000000000000000000) - end + # Bug #20654 + it "returns 10**precision.abs when precision.abs has more digits than self" do + send(@method, 123).ceil(-20).should.eql?(100000000000000000000) + send(@method, 123).ceil(-50).should.eql?(100000000000000000000000000000000000000000000000000) end end end diff --git a/spec/ruby/core/integer/shared/integer_floor_precision.rb b/spec/ruby/core/integer/shared/integer_floor_precision.rb index 4c5888c6c4..6247907d4c 100644 --- a/spec/ruby/core/integer/shared/integer_floor_precision.rb +++ b/spec/ruby/core/integer/shared/integer_floor_precision.rb @@ -33,11 +33,10 @@ describe :integer_floor_precision, shared: true do send(@method, -123).floor(-3).should.eql?(-1000) end - ruby_bug "#20654", ""..."3.4" do - it "returns -(10**precision.abs) when self is negative and precision.abs is larger than the number digits of self" do - send(@method, -123).floor(-20).should.eql?(-100000000000000000000) - send(@method, -123).floor(-50).should.eql?(-100000000000000000000000000000000000000000000000000) - end + # Bug #20654 + it "returns -(10**precision.abs) when self is negative and precision.abs is larger than the number digits of self" do + send(@method, -123).floor(-20).should.eql?(-100000000000000000000) + send(@method, -123).floor(-50).should.eql?(-100000000000000000000000000000000000000000000000000) end end end |
