diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-01 18:09:58 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-01 18:09:58 +0000 |
commit | 157dd91713ff9068d7e77e2649f5ac4d65cef6b6 (patch) | |
tree | bb72b676d1494ce812db793ea7d80527c32c26c5 /test/bigdecimal | |
parent | 4050436e57ce02f20058c90185f8711c299c8d3c (diff) |
merge revision(s) 41623,41723: [Backport #6862] [Backport #8587]
* ext/bigdecimal/bigdecimal.c (BigMath_s_exp): Fix for the cases when
the argument x is not a BigDecimal.
This change is based on the patch made by Garth Snyder.
[Fix GH-332] https://github.com/ruby/ruby/pull/332
This change is based on the patch made by Heesob Park and Garth Snyder.
[Bug #6862] [ruby-core:47145]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@41733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/bigdecimal')
-rw-r--r-- | test/bigdecimal/test_bigdecimal.rb | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index 07c79a8874..5cbafdafd4 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -1276,11 +1276,35 @@ class TestBigDecimal < Test::Unit::TestCase end def test_BigMath_exp - n = 20 - assert_in_epsilon(Math.exp(n), BigMath.exp(BigDecimal("20"), n)) - assert_in_epsilon(Math.exp(40), BigMath.exp(BigDecimal("40"), n)) - assert_in_epsilon(Math.exp(-n), BigMath.exp(BigDecimal("-20"), n)) - assert_in_epsilon(Math.exp(-40), BigMath.exp(BigDecimal("-40"), n)) + prec = 20 + assert_in_epsilon(Math.exp(20), BigMath.exp(BigDecimal("20"), prec)) + assert_in_epsilon(Math.exp(40), BigMath.exp(BigDecimal("40"), prec)) + assert_in_epsilon(Math.exp(-20), BigMath.exp(BigDecimal("-20"), prec)) + assert_in_epsilon(Math.exp(-40), BigMath.exp(BigDecimal("-40"), prec)) + end + + def test_BigMath_exp_with_float + prec = 20 + assert_in_epsilon(Math.exp(20), BigMath.exp(20.0, prec)) + assert_in_epsilon(Math.exp(40), BigMath.exp(40.0, prec)) + assert_in_epsilon(Math.exp(-20), BigMath.exp(-20.0, prec)) + assert_in_epsilon(Math.exp(-40), BigMath.exp(-40.0, prec)) + end + + def test_BigMath_exp_with_fixnum + prec = 20 + assert_in_epsilon(Math.exp(20), BigMath.exp(20, prec)) + assert_in_epsilon(Math.exp(40), BigMath.exp(40, prec)) + assert_in_epsilon(Math.exp(-20), BigMath.exp(-20, prec)) + assert_in_epsilon(Math.exp(-40), BigMath.exp(-40, prec)) + end + + def test_BigMath_exp_with_rational + prec = 20 + assert_in_epsilon(Math.exp(20), BigMath.exp(Rational(40,2), prec)) + assert_in_epsilon(Math.exp(40), BigMath.exp(Rational(80,2), prec)) + assert_in_epsilon(Math.exp(-20), BigMath.exp(Rational(-40,2), prec)) + assert_in_epsilon(Math.exp(-40), BigMath.exp(Rational(-80,2), prec)) end def test_BigMath_exp_under_gc_stress |