summaryrefslogtreecommitdiff
path: root/test/ruby/test_rational.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-16 01:53:52 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-16 01:53:52 +0000
commitb296e29035a18e44c640a4f28f220169374f921a (patch)
treeb3afe8df4f6c6653a47b3d793f714368f7aeaf80 /test/ruby/test_rational.rb
parent1e07906a423653b4f97db9599e5924366484ecb2 (diff)
rational.c: zero division
* rational.c (read_rat_nos): denominator cannot be 0, raise zero division in that case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_rational.rb')
-rw-r--r--test/ruby/test_rational.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb
index 6185611a5c..ed4c5b1006 100644
--- a/test/ruby/test_rational.rb
+++ b/test/ruby/test_rational.rb
@@ -776,6 +776,11 @@ class Rational_Test < Test::Unit::TestCase
ng[5, 3, '5/3x']
end
+ def test_parse_zero_denominator
+ assert_raise(ZeroDivisionError) {"1/0".to_r}
+ assert_raise(ZeroDivisionError) {Rational("1/0")}
+ end
+
def test_to_i
assert_equal(1, Rational(3,2).to_i)
assert_equal(1, Integer(Rational(3,2)))