summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--complex.c7
-rw-r--r--test/test_mathn.rb1
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 <naruse@ruby-lang.org>
+
+ * 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 <naruse@ruby-lang.org>
* 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