* 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
This commit is contained in:
naruse 2012-04-08 17:53:51 +00:00
Родитель fdc3882820
Коммит 71d114297f
3 изменённых файлов: 11 добавлений и 2 удалений

Просмотреть файл

@ -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):

Просмотреть файл

@ -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));
}

Просмотреть файл

@ -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