Make reciprocal properly of non-integral rational [Bug #17572]
This commit is contained in:
parent
37258b64c7
commit
a55eb9a2af
@ -1868,7 +1868,7 @@ VALUE
|
|||||||
rb_rational_reciprocal(VALUE x)
|
rb_rational_reciprocal(VALUE x)
|
||||||
{
|
{
|
||||||
get_dat1(x);
|
get_dat1(x);
|
||||||
return f_rational_new_no_reduce2(CLASS_OF(x), dat->den, dat->num);
|
return nurat_convert(CLASS_OF(x), dat->den, dat->num, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -613,6 +613,13 @@ class Rational_Test < Test::Unit::TestCase
|
|||||||
assert_nothing_raised(TypeError, '[Bug #5020] [ruby-dev:44088]') do
|
assert_nothing_raised(TypeError, '[Bug #5020] [ruby-dev:44088]') do
|
||||||
Rational(1,2).coerce(Complex(1,1))
|
Rational(1,2).coerce(Complex(1,1))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
assert_raise(ZeroDivisionError) do
|
||||||
|
1 / 0r.coerce(0+0i)[0]
|
||||||
|
end
|
||||||
|
assert_raise(ZeroDivisionError) do
|
||||||
|
1 / 0r.coerce(0.0+0i)[0]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class ObjectX
|
class ObjectX
|
||||||
|
Loading…
x
Reference in New Issue
Block a user