summaryrefslogtreecommitdiff
path: root/test/bigdecimal
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-11-26 14:04:58 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-11-26 14:04:58 +0000
commit0434b0f0986cf6e0100f605fb27c1c871075b1da (patch)
tree8b451926eb627d1672ab4d5f29dffafa12319c0b /test/bigdecimal
parent527701d55ba63b20ee4379cd5ed8260f00387a6f (diff)
* ext/bigdecimal/bigdecimal.c (VpException): bigdecimal zero
division should raise FloatDomainError if mode VP_EXCEPTION_ZERODIVIDE is set. [ruby-dev:37204] * ext/bigdecimal/bigdecimal.c (BigDecimal_mode): should handle VP_EXCEPTION_ZERODIVIDE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/bigdecimal')
-rw-r--r--test/bigdecimal/test_bigdecimal.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb
index 98fad67..d129d93 100644
--- a/test/bigdecimal/test_bigdecimal.rb
+++ b/test/bigdecimal/test_bigdecimal.rb
@@ -77,6 +77,7 @@ class TestBigDecimal < Test::Unit::TestCase
end
def test_exception_zerodivide
+ BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false)
_test_mode(BigDecimal::EXCEPTION_ZERODIVIDE) { 1 / BigDecimal.new("0") }
_test_mode(BigDecimal::EXCEPTION_ZERODIVIDE) { -1 / BigDecimal.new("0") }
end
@@ -275,6 +276,7 @@ class TestBigDecimal < Test::Unit::TestCase
def test_finite_infinite_nan
BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false)
+ BigDecimal.mode(BigDecimal::EXCEPTION_ZERODIVIDE, false)
x = BigDecimal.new("0")
assert_equal(true, x.finite?)
@@ -305,7 +307,7 @@ class TestBigDecimal < Test::Unit::TestCase
assert_equal(0, x.to_i)
assert_raise(FloatDomainError){( 1 / x).to_i}
assert_raise(FloatDomainError){(-1 / x).to_i}
- assert_raise(FloatDomainError){( 0 / x).to_i}
+ assert_raise(FloatDomainError) {( 0 / x).to_i}
x = BigDecimal.new("1")
assert_equal(1, x.to_i)
x = BigDecimal.new((2**100).to_s)
@@ -315,6 +317,7 @@ class TestBigDecimal < Test::Unit::TestCase
def test_to_f
BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false)
BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false)
+ BigDecimal.mode(BigDecimal::EXCEPTION_ZERODIVIDE, false)
x = BigDecimal.new("0")
assert_instance_of(Float, x.to_f)
@@ -616,6 +619,7 @@ class TestBigDecimal < Test::Unit::TestCase
def test_sign
BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false)
BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false)
+ BigDecimal.mode(BigDecimal::EXCEPTION_ZERODIVIDE, false)
assert_equal(BigDecimal::SIGN_POSITIVE_ZERO, BigDecimal.new("0").sign)
assert_equal(BigDecimal::SIGN_NEGATIVE_ZERO, BigDecimal.new("-0").sign)