diff options
author | Kenta Murata <mrkn@mrkn.jp> | 2021-12-09 21:35:33 +0900 |
---|---|---|
committer | Kenta Murata <mrkn@mrkn.jp> | 2021-12-24 02:29:00 +0900 |
commit | 98918209b7260b4ecb7ea503728ae3f0853866e0 (patch) | |
tree | 579ba91cbf4faf50c119eb81bdca35945781de61 /test | |
parent | d0897e3f3afdc6d1fdb0fa60bdf4b0cb80c7de03 (diff) |
[ruby/bigdecimal] Allow passing both float and precision in BigDecimal#div
Fix GH-212.
https://github.com/ruby/bigdecimal/commit/900bb7fcf5
Diffstat (limited to 'test')
-rw-r--r-- | test/bigdecimal/test_bigdecimal.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index 273abf7885..9e8f0d593b 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -1091,6 +1091,16 @@ class TestBigDecimal < Test::Unit::TestCase end end + def test_div_bigdecimal_with_float_and_precision + x = BigDecimal(5) + y = 5.1 + assert_equal(x.div(BigDecimal(y, 0), 8), + x.div(y, 8)) + + assert_equal(x.div(BigDecimal(y, 0), 100), + x.div(y, 100)) + end + def test_abs_bigdecimal x = BigDecimal((2**100).to_s) assert_equal(1267650600228229401496703205376, x.abs) |