diff options
author | nagachika <nagachika@ruby-lang.org> | 2021-02-11 13:34:05 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2021-02-11 13:52:00 +0900 |
commit | 4b6df7f735c10f326f09a44fe38dc10b05ced21c (patch) | |
tree | 3a16a08a0b14629951a454483b1f8f721380b795 | |
parent | 9cc8b2a672f50fa9a849105353e332d3a72d7b28 (diff) |
merge revision(s) a55eb9a2af7950d180d9d31ffde2bce66710f44f: [Backport #17572]
Make reciprocal properly of non-integral rational [Bug #17572]
---
rational.c | 2 +-
test/ruby/test_rational.rb | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
-rw-r--r-- | rational.c | 2 | ||||
-rw-r--r-- | test/ruby/test_rational.rb | 7 | ||||
-rw-r--r-- | version.h | 2 |
3 files changed, 9 insertions, 2 deletions
diff --git a/rational.c b/rational.c index c606f3c625..dc01425298 100644 --- a/rational.c +++ b/rational.c @@ -1875,7 +1875,7 @@ VALUE rb_rational_reciprocal(VALUE 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); } /* diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb index 301890b620..5676b41445 100644 --- a/test/ruby/test_rational.rb +++ b/test/ruby/test_rational.rb @@ -598,6 +598,13 @@ class Rational_Test < Test::Unit::TestCase assert_nothing_raised(TypeError, '[Bug #5020] [ruby-dev:44088]') do Rational(1,2).coerce(Complex(1,1)) 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 class ObjectX @@ -2,7 +2,7 @@ # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 3 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 152 +#define RUBY_PATCHLEVEL 153 #define RUBY_RELEASE_YEAR 2021 #define RUBY_RELEASE_MONTH 2 |