summaryrefslogtreecommitdiff
path: root/test/bigdecimal/test_bigdecimal.rb
diff options
context:
space:
mode:
authorKenta Murata <mrkn@mrkn.jp>2021-01-15 10:44:45 +0900
committerKenta Murata <mrkn@mrkn.jp>2021-01-16 00:09:26 +0900
commitb1306445842eee53e23fd932a85d252d183e63b5 (patch)
tree276ba3b2b44bfc6c4a25b0d19f4478dbf98e99ac /test/bigdecimal/test_bigdecimal.rb
parent9d0c5e2754c72936d604405152aebc149675a2e6 (diff)
[ruby/bigdecimal] Fix for the coerce cases in divide and DoDivmod
https://github.com/ruby/bigdecimal/commit/1cb92487f7
Diffstat (limited to 'test/bigdecimal/test_bigdecimal.rb')
-rw-r--r--test/bigdecimal/test_bigdecimal.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb
index 0063fb9..99f92c4 100644
--- a/test/bigdecimal/test_bigdecimal.rb
+++ b/test/bigdecimal/test_bigdecimal.rb
@@ -963,6 +963,15 @@ class TestBigDecimal < Test::Unit::TestCase
assert_kind_of(BigDecimal, BigDecimal("3") / 1.quo(3))
end
+ def test_div_with_complex
+ q = BigDecimal("3") / 1i
+ assert_kind_of(Complex, q)
+ end
+
+ def test_div_error
+ assert_raise(TypeError) { BigDecimal(20) / '2' }
+ end
+
def test_mod
x = BigDecimal((2**100).to_s)
assert_equal(1, x % 3)
@@ -1006,6 +1015,10 @@ class TestBigDecimal < Test::Unit::TestCase
assert_raise(ZeroDivisionError){BigDecimal("0").divmod(0)}
end
+ def test_divmod_error
+ assert_raise(TypeError) { BigDecimal(20).divmod('2') }
+ end
+
def test_add_bigdecimal
x = BigDecimal((2**100).to_s)
assert_equal(3000000000000000000000000000000, x.add(x, 1))