diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-07-11 19:20:53 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-07-11 20:04:29 +0900 |
commit | 3e7d002118a92fad5934e11c75be6768a1476c1b (patch) | |
tree | e9f437327b5c743622a97c092ddadc2d99cb0bc5 /test/ruby | |
parent | cd069df36596d9bf7a6db8aaa0dcefdafb233a91 (diff) | |
download | ruby-3e7d002118a92fad5934e11c75be6768a1476c1b.tar.gz |
Check exception flag as a bool [Bug #15987]
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_complex.rb | 6 | ||||
-rw-r--r-- | test/ruby/test_float.rb | 6 | ||||
-rw-r--r-- | test/ruby/test_integer.rb | 6 | ||||
-rw-r--r-- | test/ruby/test_io.rb | 12 | ||||
-rw-r--r-- | test/ruby/test_rational.rb | 6 |
5 files changed, 36 insertions, 0 deletions
diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb index 60a46d737d..2a72f3bcb9 100644 --- a/test/ruby/test_complex.rb +++ b/test/ruby/test_complex.rb @@ -868,6 +868,12 @@ class Complex_Test < Test::Unit::TestCase end + def test_Complex_with_invalid_exception + assert_raise(ArgumentError) { + Complex("0", exception: 1) + } + end + def test_Complex_without_exception assert_nothing_raised(ArgumentError){ assert_equal(nil, Complex('5x', exception: false)) diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index 3453440694..02bafb0303 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -802,6 +802,12 @@ class TestFloat < Test::Unit::TestCase assert_raise(ArgumentError, bug4310) {under_gc_stress {Float('a'*10000)}} end + def test_Float_with_invalid_exception + assert_raise(ArgumentError) { + Float("0", exception: 1) + } + end + def test_Float_with_exception_keyword assert_raise(ArgumentError) { Float(".", exception: true) diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb index 2334cab50a..84730b2a5d 100644 --- a/test/ruby/test_integer.rb +++ b/test/ruby/test_integer.rb @@ -193,6 +193,12 @@ class TestInteger < Test::Unit::TestCase end def test_Integer_with_exception_keyword + assert_raise(ArgumentError) { + Integer("0", exception: 1) + } + end + + def test_Integer_with_exception_keyword assert_nothing_raised(ArgumentError) { assert_equal(nil, Integer("1z", exception: false)) } diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 4f66685f9b..3c5dc7671a 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1509,6 +1509,12 @@ class TestIO < Test::Unit::TestCase } end if have_nonblock? + def test_read_nonblock_invalid_exception + with_pipe {|r, w| + assert_raise(ArgumentError) {r.read_nonblock(4096, exception: 1)} + } + end if have_nonblock? + def test_read_nonblock_no_exceptions skip '[ruby-core:90895] MJIT worker may leave fd open in a forked child' if RubyVM::MJIT.enabled? # TODO: consider acquiring GVL from MJIT worker. with_pipe {|r, w| @@ -1545,6 +1551,12 @@ class TestIO < Test::Unit::TestCase } end if have_nonblock? + def test_write_nonblock_invalid_exception + with_pipe {|r, w| + assert_raise(ArgumentError) {w.write_nonblock(4096, exception: 1)} + } + end if have_nonblock? + def test_write_nonblock_no_exceptions with_pipe {|r, w| loop { diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb index a8cdf22a49..301890b620 100644 --- a/test/ruby/test_rational.rb +++ b/test/ruby/test_rational.rb @@ -808,6 +808,12 @@ class Rational_Test < Test::Unit::TestCase assert_raise(ZeroDivisionError) {Rational("1/0")} end + def test_Rational_with_invalid_exception + assert_raise(ArgumentError) { + Rational("1/1", exception: 1) + } + end + def test_Rational_without_exception assert_nothing_raised(ArgumentError) { assert_equal(nil, Rational("5/3x", exception: false)) |