summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-11 01:09:39 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-11 01:09:39 +0000
commit24eff272f19cd5d3c7a5930fade84bd9a040d2e5 (patch)
treef02250e8d951aedbbd775aeae56d66ac10de91ee
parent322ce91a97497d48224ea3f5578fce514103b481 (diff)
merge revision(s) 41623,41723: [Backport #8603]
* 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_1_9_3@41909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--ext/bigdecimal/bigdecimal.c2
-rw-r--r--test/bigdecimal/test_bigdecimal.rb34
-rw-r--r--version.h6
4 files changed, 41 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 8784df9fff..e5acd518a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Thu Jul 11 10:07:15 2013 Kenta Murata <mrkn@mrkn.jp>
+
+ * 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 Heesob Park and Garth Snyder.
+ [Bug #6862] [ruby-core:47145]
+ [Fix GH-332] https://github.com/ruby/ruby/pull/332
+
Wed Jul 10 10:27:12 2013 NAKAMURA Usaku <usa@ruby-lang.org>
* include/ruby/intern.h (rb_path_next, rb_path_skip_prefix,
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 14f80b1929..8564730756 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -2554,7 +2554,7 @@ BigMath_s_exp(VALUE klass, VALUE x, VALUE vprec)
else if (vx == NULL) {
cannot_be_coerced_into_BigDecimal(rb_eArgError, x);
}
- RB_GC_GUARD(vx->obj);
+ x = RB_GC_GUARD(vx->obj);
n = prec + rmpd_double_figures();
negative = VpGetSign(vx) < 0;
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb
index 055b0ff4f0..02467937e5 100644
--- a/test/bigdecimal/test_bigdecimal.rb
+++ b/test/bigdecimal/test_bigdecimal.rb
@@ -1210,11 +1210,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
diff --git a/version.h b/version.h
index 66f6c51bd0..6a35f0b7e8 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 451
+#define RUBY_PATCHLEVEL 452
-#define RUBY_RELEASE_DATE "2013-07-10"
+#define RUBY_RELEASE_DATE "2013-07-11"
#define RUBY_RELEASE_YEAR 2013
#define RUBY_RELEASE_MONTH 7
-#define RUBY_RELEASE_DAY 10
+#define RUBY_RELEASE_DAY 11
#include "ruby/version.h"