diff options
Diffstat (limited to 'test/ruby/test_exception.rb')
-rw-r--r-- | test/ruby/test_exception.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index 32b87f2d92..92438ad742 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -479,16 +479,31 @@ end.join def test_cause msg = "[Feature #8257]" + cause = nil e = assert_raise(StandardError) { begin raise msg rescue => e - assert_nil(e.cause, msg) + cause = e.cause raise StandardError end } + assert_nil(cause, msg) cause = e.cause assert_instance_of(RuntimeError, cause, msg) assert_equal(msg, cause.message, msg) end + + def test_cause_reraised + msg = "[Feature #8257]" + cause = nil + e = assert_raise(RuntimeError) { + begin + raise msg + rescue => e + raise e + end + } + assert_not_same(e, e.cause, "#{msg}: should not be recursive") + end end |