summaryrefslogtreecommitdiff
path: root/test/ruby/test_rational.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-24 02:08:36 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-24 02:08:36 +0000
commitf954caea430439ce4cb2360aea25d29b8de5dfef (patch)
treee798916262b7a73f6b716df8d4ed7aa9929d2e65 /test/ruby/test_rational.rb
parent623160916dccc23d36bcceaf8014242903c6b04a (diff)
rational.c: segfault on Rational exponent
* rational.c (read_num): fix segfault on Rational() with positive but less than the length of fractional part exponent. should be negated to convert to divisor which is a reciprocal. [ruby-core:85783] [Bug #14547] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_rational.rb')
-rw-r--r--test/ruby/test_rational.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb
index 74fbbb49ec..fe267d5a1f 100644
--- a/test/ruby/test_rational.rb
+++ b/test/ruby/test_rational.rb
@@ -110,6 +110,10 @@ class Rational_Test < Test::Unit::TestCase
assert_equal(Rational(3),Rational('3'))
assert_equal(Rational(1),Rational('3.0','3.0'))
assert_equal(Rational(1),Rational('3/3','3/3'))
+ assert_equal(Rational(111, 10), Rational('1.11e+1'))
+ assert_equal(Rational(111, 10), Rational('1.11e1'))
+ assert_equal(Rational(111, 100), Rational('1.11e0'))
+ assert_equal(Rational(111, 1000), Rational('1.11e-1'))
assert_raise(TypeError){Rational(nil)}
assert_raise(ArgumentError){Rational('')}
assert_raise_with_message(ArgumentError, /\u{221a 2668}/) {