summaryrefslogtreecommitdiff
path: root/test/bigdecimal
diff options
context:
space:
mode:
authorKenta Murata <mrkn@mrkn.jp>2020-12-19 11:55:46 +0900
committerKenta Murata <mrkn@mrkn.jp>2020-12-19 22:13:58 +0900
commit654f6fbf19c0ca2e01765a909b4d952b7f0f5baa (patch)
tree4596101121252a268228a757e62ace9ffb861fa8 /test/bigdecimal
parentff9e40811c67b1090966b655f7adc0684fc58abe (diff)
[bigdecimal] Make BigDecimal#precs deprecated
https://github.com/ruby/bigdecimal/commit/7e80e6e145 https://github.com/ruby/bigdecimal/commit/0ed7846e8c
Diffstat (limited to 'test/bigdecimal')
-rw-r--r--test/bigdecimal/test_bigdecimal.rb22
1 files changed, 16 insertions, 6 deletions
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb
index 59726adabb..3003e44a6e 100644
--- a/test/bigdecimal/test_bigdecimal.rb
+++ b/test/bigdecimal/test_bigdecimal.rb
@@ -610,12 +610,22 @@ class TestBigDecimal < Test::Unit::TestCase
assert_operator(BigDecimal((2**100).to_s), :==, d)
end
+ def test_precs_deprecated
+ assert_warn(/BigDecimal#precs is deprecated and will be removed in the future/) do
+ BigDecimal("1").precs
+ end
+ end
+
def test_precs
- a = BigDecimal("1").precs
- assert_instance_of(Array, a)
- assert_equal(2, a.size)
- assert_kind_of(Integer, a[0])
- assert_kind_of(Integer, a[1])
+ assert_separately(["-rbigdecimal"], "#{<<~"begin;"}\n#{<<~'end;'}")
+ begin;
+ $VERBOSE = nil
+ a = BigDecimal("1").precs
+ assert_instance_of(Array, a)
+ assert_equal(2, a.size)
+ assert_kind_of(Integer, a[0])
+ assert_kind_of(Integer, a[1])
+ end;
end
def test_hash
@@ -764,7 +774,7 @@ class TestBigDecimal < Test::Unit::TestCase
assert_equal(BigDecimal("0.1"), a, '[ruby-core:34318]')
a, b = BigDecimal("0.11111").coerce(1.quo(3))
- assert_equal(BigDecimal("0." + "3"*a.precs[0]), a)
+ assert_equal(BigDecimal("0." + "3"*a.precision), a)
assert_nothing_raised(TypeError, '#7176') do
BigDecimal('1') + Rational(1)