error.c(exc_full_message): Exception#full_message

Add a method to retrieve a String expression of an exception,
formatted in the same way that Ruby prints an uncaught exception out.

[Feature #14141]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
sorah 2017-12-12 11:47:16 +00:00
parent 838f23ae34
commit 0d7718896c
4 changed files with 109 additions and 53 deletions

View file

@ -1094,4 +1094,15 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
}
end;
end
def test_full_message
test_method = "def foo; raise 'testerror'; end"
out1, err1, status1 = EnvUtil.invoke_ruby(['-e', "#{test_method}; begin; foo; rescue => e; puts e.full_message; end"], '', true, true)
assert(status1.success?)
assert(err1.empty?, "expected nothing wrote to $stdout by #long_message")
_, err2, status1 = EnvUtil.invoke_ruby(['-e', "#{test_method}; begin; foo; end"], '', true, true)
assert_equal(err2, out1)
end
end