summaryrefslogtreecommitdiff
path: root/test/bigdecimal/test_bigdecimal.rb
diff options
context:
space:
mode:
authorMaciej Rzasa <maciejrzasa@gmail.com>2022-11-30 22:38:25 +0100
committergit <svn-admin@ruby-lang.org>2023-02-17 17:46:27 +0000
commit36e3d46d35b6a904533e58809369054b135c33d7 (patch)
treef7bd9cefc8281e5a04feb2e0ab31a9887014dea3 /test/bigdecimal/test_bigdecimal.rb
parent81dc3a1780319f4bc232af407edea60a35d251ed (diff)
[ruby/bigdecimal] Handle correctly #remainder with infinity. Fixes
https://github.com/ruby/bigdecimal/pull/187 https://github.com/ruby/bigdecimal/commit/4b8572d452
Diffstat (limited to 'test/bigdecimal/test_bigdecimal.rb')
-rw-r--r--test/bigdecimal/test_bigdecimal.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb
index 9c3d72ecaf..2fc22d224f 100644
--- a/test/bigdecimal/test_bigdecimal.rb
+++ b/test/bigdecimal/test_bigdecimal.rb
@@ -2260,6 +2260,17 @@ class TestBigDecimal < Test::Unit::TestCase
assert_equal(BigDecimal(minus_ullong_max.to_s), BigDecimal(minus_ullong_max), "[GH-200]")
end
+ def test_reminder_infinity_gh_187
+ # https://github.com/ruby/bigdecimal/issues/187
+ BigDecimal.save_exception_mode do
+ BigDecimal.mode(BigDecimal::EXCEPTION_INFINITY, false)
+ BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false)
+ bd = BigDecimal("4.2")
+ assert_equal(bd.remainder(BigDecimal("+Infinity")), bd)
+ assert_equal(bd.remainder(BigDecimal("-Infinity")), bd)
+ end
+ end
+
def assert_no_memory_leak(code, *rest, **opt)
code = "8.times {20_000.times {begin #{code}; rescue NoMemoryError; end}; GC.start}"
super(["-rbigdecimal"],