summaryrefslogtreecommitdiff
path: root/test/ruby/test_numeric.rb
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2021-03-10 13:15:50 -0800
committerJeremy Evans <code@jeremyevans.net>2021-03-12 07:35:18 -0800
commitaaab3b1de943c3317e115d623ffc7908b4c96578 (patch)
tree8665765ba9bd35801f514322178c63974c90ae32 /test/ruby/test_numeric.rb
parent701001e36ea99f0c253eeb0721706af77de0ffdd (diff)
Fix integer/float remainder with infinity argument of opposite sign
Previously, the result was incorrect: 4.remainder(-Float::INFINITY) Before: => NaN After: => 4 4.2.remainder(-Float::INFINITY) Before: => NaN After: => 4.2 Fixes [Bug #6120]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4257
Diffstat (limited to 'test/ruby/test_numeric.rb')
-rw-r--r--test/ruby/test_numeric.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_numeric.rb b/test/ruby/test_numeric.rb
index c8751fbc57..066afc83a2 100644
--- a/test/ruby/test_numeric.rb
+++ b/test/ruby/test_numeric.rb
@@ -384,6 +384,18 @@ class TestNumeric < Test::Unit::TestCase
end;
end
+ def test_remainder_infinity
+ assert_equal(4, 4.remainder(Float::INFINITY))
+ assert_equal(4, 4.remainder(-Float::INFINITY))
+ assert_equal(-4, -4.remainder(Float::INFINITY))
+ assert_equal(-4, -4.remainder(-Float::INFINITY))
+
+ assert_equal(4.2, 4.2.remainder(Float::INFINITY))
+ assert_equal(4.2, 4.2.remainder(-Float::INFINITY))
+ assert_equal(-4.2, -4.2.remainder(Float::INFINITY))
+ assert_equal(-4.2, -4.2.remainder(-Float::INFINITY))
+ end
+
def test_comparison_comparable
bug12864 = '[ruby-core:77713] [Bug #12864]'