refine parse_rat

* rational.c (read_num): return the exponent instead of the
  divisor, to get rid of huge bignums.

* rational.c (parse_rat): subtract exponents instead of reduction
  of powers.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2018-11-08 02:25:44 +00:00
parent dcfb7f6d54
commit 17e9667fe9
2 changed files with 43 additions and 25 deletions

View file

@ -120,6 +120,9 @@ class Rational_Test < Test::Unit::TestCase
assert_raise_with_message(ArgumentError, /\u{221a 2668}/) {
Rational("\u{221a 2668}")
}
assert_warning('') {
assert_predicate(Rational('1e-99999999999999999999'), :zero?)
}
assert_raise(TypeError){Rational(Object.new)}
assert_raise(TypeError){Rational(Object.new, Object.new)}