diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-16 01:53:52 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-16 01:53:52 +0000 |
commit | b296e29035a18e44c640a4f28f220169374f921a (patch) | |
tree | b3afe8df4f6c6653a47b3d793f714368f7aeaf80 /test | |
parent | 1e07906a423653b4f97db9599e5924366484ecb2 (diff) | |
download | ruby-b296e29035a18e44c640a4f28f220169374f921a.tar.gz |
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')
-rw-r--r-- | test/ruby/test_rational.rb | 5 |
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))) |