diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-15 14:08:49 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-15 14:08:49 +0000 |
commit | 549b35c1dc771d233a72466a6cae8363908f3350 (patch) | |
tree | 78e6b127454a068f74f62bd6b5b631216d0be578 /test | |
parent | e7d29c6cdadbb08d39219a05d795fe6c38414e19 (diff) | |
download | ruby-549b35c1dc771d233a72466a6cae8363908f3350.tar.gz |
eval.c: refactor exception cause
* eval.c (setup_exception): set up cause after exception to be raised
is fixed. [Feature #8257]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-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 |