diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-10-27 21:45:30 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-10-27 21:45:30 +0000 |
commit | 48af6fd544e0b3cec83af9a629059ff8d304720c (patch) | |
tree | 4a1fdbb1658f6df1921b14091d65e4d12f48cc92 /test/ruby | |
parent | 1346e39ce6e3cef0f120efde4ebf13ae045ecc02 (diff) | |
download | ruby-48af6fd544e0b3cec83af9a629059ff8d304720c.tar.gz |
Print exception's cause like Java
Print `cause` of the exception if the exception is not caught and printed
its backtraces and error message [Feature #8257]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_backtrace.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/ruby/test_backtrace.rb b/test/ruby/test_backtrace.rb index d38628cdb2..69d053b672 100644 --- a/test/ruby/test_backtrace.rb +++ b/test/ruby/test_backtrace.rb @@ -297,4 +297,36 @@ class TestBacktrace < Test::Unit::TestCase end assert_not_match(/\Acore#/, e.backtrace_locations[0].base_label) end + + def test_notty_backtrace + err = ["-:1:in `<main>': unhandled exception"] + assert_in_out_err([], "raise", [], err) + + err = ["-:2:in `foo': foo! (RuntimeError)", + "\tfrom -:4:in `<main>'"] + assert_in_out_err([], <<-"end;", [], err) + def foo + raise "foo!" + end + foo + end; + + err = ["-:7:in `rescue in bar': bar! (RuntimeError)", + "\tfrom -:4:in `bar'", + "\tfrom -:9:in `<main>'", + "\t2: from -:9:in `<main>'", + "\t1: from -:5:in `bar'", + "-:2:in `foo': foo! (RuntimeError)"] + assert_in_out_err([], <<-"end;", [], err) + def foo + raise "foo!" + end + def bar + foo + rescue + raise "bar!" + end + bar + end; + end end |