From 1bd7ae71b5da0b61cde77425ea2b67b9bd0431aa Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Sun, 28 Jul 2024 10:39:10 -0400 Subject: [PATCH] Add specs for [Bug #20654] --- core/integer/shared/integer_ceil_precision.rb | 7 +++++++ core/integer/shared/integer_floor_precision.rb | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/core/integer/shared/integer_ceil_precision.rb b/core/integer/shared/integer_ceil_precision.rb index 8fe656ab0..9f31c2cf6 100644 --- a/core/integer/shared/integer_ceil_precision.rb +++ b/core/integer/shared/integer_ceil_precision.rb @@ -32,5 +32,12 @@ send(@method, -123).ceil(-2).should.eql?(-100) send(@method, -123).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 + end end end diff --git a/core/integer/shared/integer_floor_precision.rb b/core/integer/shared/integer_floor_precision.rb index 09b00674c..4c5888c6c 100644 --- a/core/integer/shared/integer_floor_precision.rb +++ b/core/integer/shared/integer_floor_precision.rb @@ -32,5 +32,12 @@ send(@method, -123).floor(-2).should.eql?(-200) 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 + end end end