summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKenta Murata <mrkn@mrkn.jp>2019-10-09 10:27:08 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-07-06 01:15:46 +0900
commitf00efef30ad6eca30e5674493dacbd25b425a4eb (patch)
treefb772d0bb5ae51d9be23a537c1fe5825e8ec94e1 /test
parentceb9d516c6d17b0619cf53dfba7cb7b29fe073e4 (diff)
[ruby/bigdecimal] Support a Complex in Kernel.BigDecimal()
https://github.com/ruby/bigdecimal/commit/00795cb01f
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3295
Diffstat (limited to 'test')
-rw-r--r--test/bigdecimal/test_bigdecimal.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb
index 6928834907..80ef39afd0 100644
--- a/test/bigdecimal/test_bigdecimal.rb
+++ b/test/bigdecimal/test_bigdecimal.rb
@@ -137,6 +137,14 @@ class TestBigDecimal < Test::Unit::TestCase
end
end
+ def test_BigDecimal_with_complex
+ assert_equal(BigDecimal("1"), BigDecimal(Complex(1, 0)))
+ assert_equal(BigDecimal("0.333333333333333333333"), BigDecimal(Complex(1.quo(3), 0), 21))
+ assert_equal(BigDecimal("0.1235"), BigDecimal(Complex(0.1234567, 0), 4))
+
+ assert_raise_with_message(ArgumentError, "Unable to make a BigDecimal from non-zero imaginary number") { BigDecimal(Complex(1, 1)) }
+ end
+
def test_BigDecimal_with_big_decimal
assert_equal(BigDecimal(1), BigDecimal(BigDecimal(1)))
assert_equal(BigDecimal('+0'), BigDecimal(BigDecimal('+0')))