From d7058e10dc730b101558d21c343d784aaaf98d3f Mon Sep 17 00:00:00 2001 From: mrkn Date: Tue, 31 May 2011 15:09:38 +0000 Subject: * ext/bigdecimal/bigdecimal.c (BigDecimal_coerce): support coerce with a Rational. The precision used for instantiate a BigDecimal from the given Rational is obtained from the receiver BigDecimal. * test/bigdecimal/test_bigdecimal.rb (test_coerce): add a test for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/bigdecimal/test_bigdecimal.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test') diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index dd75dbfd64..63873d2b7c 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -485,6 +485,12 @@ class TestBigDecimal < Test::Unit::TestCase assert_instance_of(Float, a) assert_instance_of(Float, b) assert_equal(2, 1 + BigDecimal.new("1"), '[ruby-core:25697]') + + a, b = BigDecimal("1").coerce(1.quo(10)) + assert_equal(BigDecimal("0.1"), a, '[ruby-core:34318]') + + a, b = BigDecimal("0.11111").coerce(1.quo(3)) + assert_equal(BigDecimal("0." + "3"*a.precs[0]), a) end def test_uplus -- cgit v1.2.3