From 71d114297f6891937ec680c4fa0e2455e12af4f4 Mon Sep 17 00:00:00 2001 From: naruse Date: Sun, 8 Apr 2012 17:53:51 +0000 Subject: * complex.c (nucomp_expt): the result of f_complex_new2 may be a fixnum with mathn. [ruby-core:44170] [Bug #6267] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ complex.c | 7 +++++-- test/test_mathn.rb | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 828fd02ad9..219e034279 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Apr 9 02:52:03 2012 NARUSE, Yui + + * complex.c (nucomp_expt): the result of f_complex_new2 may be a fixnum + with mathn. [ruby-core:44170] [Bug #6267] + Sun Apr 8 22:46:01 2012 NARUSE, Yui * ext/json/generator/generator.c (generate_json_bignum): diff --git a/complex.c b/complex.c index c127a2681b..930c4453ec 100644 --- a/complex.c +++ b/complex.c @@ -887,7 +887,7 @@ nucomp_expt(VALUE self, VALUE other) if (r) break; - x = f_complex_new2(CLASS_OF(self), + x = nucomp_s_new_internal(CLASS_OF(self), f_sub(f_mul(dat->real, dat->real), f_mul(dat->imag, dat->imag)), f_mul(f_mul(TWO, dat->real), dat->imag)); @@ -896,7 +896,10 @@ nucomp_expt(VALUE self, VALUE other) z = f_mul(z, x); n--; } - return z; + { + get_dat1(z); + return f_complex_new2(CLASS_OF(self), dat->real, dat->imag); + } } return f_expt(f_reciprocal(self), f_negate(other)); } diff --git a/test/test_mathn.rb b/test/test_mathn.rb index f511adb7d5..fd0cb32c6c 100644 --- a/test/test_mathn.rb +++ b/test/test_mathn.rb @@ -6,5 +6,6 @@ class TestMathn < Test::Unit::TestCase def test_power assert_in_out_err ['-r', 'mathn', '-e', 'a=1**2;!a'], "", [], [], '[ruby-core:25740]' assert_in_out_err ['-r', 'mathn', '-e', 'a=(1<<126)**2;!a'], "", [], [], '[ruby-core:25740]' + assert_in_out_err ['-r', 'mathn/complex', '-e', 'a=Complex(0,1)**5;!a'], "", [], [], '[ruby-core:44170]' end end -- cgit v1.2.3