summaryrefslogtreecommitdiff
path: root/test/bigdecimal/test_bigdecimal.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/bigdecimal/test_bigdecimal.rb')
-rw-r--r--test/bigdecimal/test_bigdecimal.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb
index 467b5e1b0b..53979340a1 100644
--- a/test/bigdecimal/test_bigdecimal.rb
+++ b/test/bigdecimal/test_bigdecimal.rb
@@ -343,6 +343,16 @@ class TestBigDecimal < Test::Unit::TestCase
BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false)
assert_kind_of(Float, x .to_f)
assert_kind_of(Float, (-x).to_f)
+
+ BigDecimal.mode(BigDecimal::EXCEPTION_UNDERFLOW, true)
+ assert_raise(FloatDomainError) {
+ BigDecimal("1e#{Float::MIN_10_EXP - 2*Float::DIG}").to_f }
+ assert_raise(FloatDomainError) {
+ BigDecimal("-1e#{Float::MIN_10_EXP - 2*Float::DIG}").to_f }
+
+ BigDecimal.mode(BigDecimal::EXCEPTION_UNDERFLOW, false)
+ assert_equal( 0.0, BigDecimal("1e#{Float::MIN_10_EXP - 2*Float::DIG}").to_f)
+ assert_equal(-0.0, BigDecimal("-1e#{Float::MIN_10_EXP - 2*Float::DIG}").to_f)
end
def test_coerce