diff options
| author | nagachika <nagachika@ruby-lang.org> | 2024-07-15 09:50:14 +0900 |
|---|---|---|
| committer | nagachika <nagachika@ruby-lang.org> | 2024-07-15 09:50:14 +0900 |
| commit | 90f4c5dc73af3fff76500dd4223792a6d9f58636 (patch) | |
| tree | 76455e0344fcf2608bce117271533bc294b2b917 /test/ruby | |
| parent | a54c717c7a74b91a3cdf20742c355e3ea42052d1 (diff) | |
merge revision(s) dc146babf47a84bbd1f176d766637d4a40327019, f23d5028059078a346efc977287b669d494a5a3f, a0f7de814ae5c299d6ce99bed5fb308a05d50ba0: [Backport #20296]
[Bug #20296] Clear errinfo when `exception: false`
[Bug #20296] Refine the test
[Bug #20296] Fix the default assertion message
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_complex.rb | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb index edbdffd069..b262b2c1c1 100644 --- a/test/ruby/test_complex.rb +++ b/test/ruby/test_complex.rb @@ -915,31 +915,27 @@ class Complex_Test < Test::Unit::TestCase } end - def test_Complex_without_exception - assert_nothing_raised(ArgumentError){ - assert_equal(nil, Complex('5x', exception: false)) - } - assert_nothing_raised(ArgumentError){ - assert_equal(nil, Complex(nil, exception: false)) - } - assert_nothing_raised(ArgumentError){ - assert_equal(nil, Complex(Object.new, exception: false)) - } - assert_nothing_raised(ArgumentError){ - assert_equal(nil, Complex(1, nil, exception: false)) - } - assert_nothing_raised(ArgumentError){ - assert_equal(nil, Complex(1, Object.new, exception: false)) - } + def assert_complex_with_exception(error, *args, message: "") + assert_raise(error, message) do + Complex(*args, exception: true) + end + assert_nothing_raised(error, message) do + assert_nil(Complex(*args, exception: false)) + assert_nil($!) + end + end + + def test_Complex_with_exception + assert_complex_with_exception(ArgumentError, '5x') + assert_complex_with_exception(TypeError, nil) + assert_complex_with_exception(TypeError, Object.new) + assert_complex_with_exception(TypeError, 1, nil) + assert_complex_with_exception(TypeError, 1, Object.new) o = Object.new def o.to_c; raise; end - assert_nothing_raised(ArgumentError){ - assert_equal(nil, Complex(o, exception: false)) - } - assert_nothing_raised(ArgumentError){ - assert_equal(nil, Complex(1, o, exception: false)) - } + assert_complex_with_exception(RuntimeError, o) + assert_complex_with_exception(TypeError, 1, o) end def test_respond |
