diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-14 00:17:07 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-14 00:17:07 +0000 |
commit | 0853a5cc66fe780de66802d5ac5bf997c718291d (patch) | |
tree | 80305aeec998e79aab5fcb38927391049cc01134 /test/bigdecimal | |
parent | ee63030ea9a6783b35a6eec564437e5e4cf50bcb (diff) | |
download | ruby-0853a5cc66fe780de66802d5ac5bf997c718291d.tar.gz ruby-0853a5cc66fe780de66802d5ac5bf997c718291d.tar.xz ruby-0853a5cc66fe780de66802d5ac5bf997c718291d.zip |
* ext/bigdecimal/bigdecimal.c (BigDecimalCmp): Fix comparisons [ruby-core:26646]
* test/bigdecimal/test_bigdecimal.rb (class): Fix and improve tests.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/bigdecimal')
-rw-r--r-- | test/bigdecimal/test_bigdecimal.rb | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index 2490c8469..4d2a28514 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -61,7 +61,6 @@ class TestBigDecimal < Test::Unit::TestCase x = BigDecimal.new("0.1") 100.times do x *= x - break if x == false end end end @@ -71,7 +70,6 @@ class TestBigDecimal < Test::Unit::TestCase x = BigDecimal.new("10") 100.times do x *= x - break if x == false end end end @@ -219,7 +217,20 @@ class TestBigDecimal < Test::Unit::TestCase assert_operator(1, :<, inf) end - def test_cmp_corece + def test_cmp_nan + n1 = BigDecimal.new("1") + BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false) + assert_equal(nil, BigDecimal.new("NaN") <=> n1) + assert_equal(false, BigDecimal.new("NaN") > n1) + end + + def test_cmp_failing_coercion + n1 = BigDecimal.new("1") + assert_equal(nil, n1 <=> nil) + assert_raise(ArgumentError){n1 > nil} + end + + def test_cmp_coerce n1 = BigDecimal.new("1") n2 = BigDecimal.new("2") o1 = Object.new; def o1.coerce(x); [x, BigDecimal.new("1")]; end |