summaryrefslogtreecommitdiff
path: root/test/bigdecimal
diff options
context:
space:
mode:
Diffstat (limited to 'test/bigdecimal')
-rw-r--r--test/bigdecimal/test_bigdecimal.rb2
-rw-r--r--test/bigdecimal/test_bigdecimal_util.rb8
2 files changed, 7 insertions, 3 deletions
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb
index e8fd85a5262..0063fb97431 100644
--- a/test/bigdecimal/test_bigdecimal.rb
+++ b/test/bigdecimal/test_bigdecimal.rb
@@ -917,6 +917,7 @@ class TestBigDecimal < Test::Unit::TestCase
def test_mult_with_float
assert_kind_of(BigDecimal, BigDecimal("3") * 1.5)
+ assert_equal(BigDecimal("64.4"), BigDecimal(1) * 64.4)
end
def test_mult_with_rational
@@ -955,6 +956,7 @@ class TestBigDecimal < Test::Unit::TestCase
def test_div_with_float
assert_kind_of(BigDecimal, BigDecimal("3") / 1.5)
+ assert_equal(BigDecimal("0.5"), BigDecimal(1) / 2.0)
end
def test_div_with_rational
diff --git a/test/bigdecimal/test_bigdecimal_util.rb b/test/bigdecimal/test_bigdecimal_util.rb
index 9c6973dca7f..ffd4c5f679d 100644
--- a/test/bigdecimal/test_bigdecimal_util.rb
+++ b/test/bigdecimal/test_bigdecimal_util.rb
@@ -19,11 +19,11 @@ class TestBigDecimalUtil < Test::Unit::TestCase
def test_Float_to_d_without_precision
delta = 1.0/10**(Float::DIG+1)
- assert_in_delta(BigDecimal(0.5, Float::DIG+1), 0.5.to_d, delta)
- assert_in_delta(BigDecimal(355.0/113.0, Float::DIG+1), (355.0/113.0).to_d, delta)
+ assert_in_delta(BigDecimal(0.5, 0), 0.5.to_d, delta)
+ assert_in_delta(BigDecimal(355.0/113.0, 0), (355.0/113.0).to_d, delta)
assert_equal(9.05, 9.05.to_d.to_f)
- assert_equal("9.050000000000001", 9.05.to_d.to_s('F'))
+ assert_equal("9.05", 9.05.to_d.to_s('F'))
assert_equal(Math::PI, Math::PI.to_d.to_f)
@@ -34,6 +34,8 @@ class TestBigDecimalUtil < Test::Unit::TestCase
assert_raise(TypeError) { 0.3.to_d(false) }
assert(1.1.to_d.frozen?)
+
+ assert_equal(BigDecimal("999_999.9999"), 999_999.9999.to_d)
end
def test_Float_to_d_with_precision