summaryrefslogtreecommitdiff
path: root/test/bigdecimal/test_bigdecimal.rb
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-18 13:48:21 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-18 13:48:21 +0000
commite040ff55308cca5d4f748c9bcc8f8889a32f9564 (patch)
treefcb65b075c03c004c9c6945190940a539a95f38e /test/bigdecimal/test_bigdecimal.rb
parentc3e2e0e53f0e5bfd1277152fa7705c22a44bf573 (diff)
* ext/bigdecimal/bigdecimal.c (VpCtoV): 1E1000...000 is interpreted as
Infinity. [ruby-dev:36159] * ext/bigdecimal/bigdecimal.c (VpPower): Infinity ** 1 returns Infinity instead of NaN. [ruby-dev:36159] * test/bigdecimal/test_bigdecimal.rb: add tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/bigdecimal/test_bigdecimal.rb')
-rw-r--r--test/bigdecimal/test_bigdecimal.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb
index c3899033e32..e9d1d0bdb6c 100644
--- a/test/bigdecimal/test_bigdecimal.rb
+++ b/test/bigdecimal/test_bigdecimal.rb
@@ -595,7 +595,18 @@ class TestBigDecimal < Test::Unit::TestCase
assert_equal(BigDecimal.new("-Infinity"), BigDecimal.new("-0") ** -1)
BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false)
assert_equal(true, (BigDecimal.new("NaN") ** 1).nan?)
- assert_equal(true, (BigDecimal.new("Infinity") ** 1).nan?) # OK?
+
+ assert_equal(BigDecimal::SIGN_POSITIVE_INFINITE, (BigDecimal.new("Infinity") ** 2).sign)
+ assert_equal(BigDecimal::SIGN_POSITIVE_INFINITE, (BigDecimal.new("Infinity") ** 1).sign)
+ assert_equal(1, BigDecimal.new("Infinity") ** 0)
+ assert_equal(BigDecimal::SIGN_POSITIVE_ZERO, (BigDecimal.new("Infinity") ** -1).sign)
+ assert_equal(BigDecimal::SIGN_POSITIVE_ZERO, (BigDecimal.new("Infinity") ** -2).sign)
+
+ assert_equal(BigDecimal::SIGN_POSITIVE_INFINITE, (BigDecimal.new("-Infinity") ** 2).sign)
+ assert_equal(BigDecimal::SIGN_NEGATIVE_INFINITE, (BigDecimal.new("-Infinity") ** 1).sign)
+ assert_equal(1, BigDecimal.new("-Infinity") ** 0)
+ assert_equal(BigDecimal::SIGN_NEGATIVE_ZERO, (BigDecimal.new("-Infinity") ** -1).sign)
+ assert_equal(BigDecimal::SIGN_POSITIVE_ZERO, (BigDecimal.new("-Infinity") ** -2).sign)
end
def test_limit
@@ -676,6 +687,10 @@ class TestBigDecimal < Test::Unit::TestCase
assert_equal(10, BigDecimal.new("1E+1"))
assert_equal(1, BigDecimal.new("+1"))
BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false)
- assert_equal(0, BigDecimal.new("1E1" + "0" * 100)) # OK? must it be inf?
+
+ assert_equal(BigDecimal::SIGN_POSITIVE_INFINITE, BigDecimal.new("1E1" + "0" * 10000).sign)
+ assert_equal(BigDecimal::SIGN_NEGATIVE_INFINITE, BigDecimal.new("-1E1" + "0" * 10000).sign)
+ assert_equal(BigDecimal::SIGN_POSITIVE_ZERO, BigDecimal.new("1E-1" + "0" * 10000).sign)
+ assert_equal(BigDecimal::SIGN_NEGATIVE_ZERO, BigDecimal.new("-1E-1" + "0" * 10000).sign)
end
end