From 0d7718896cfb629ad823b9ca5004465ef2063ab8 Mon Sep 17 00:00:00 2001 From: sorah Date: Tue, 12 Dec 2017 11:47:16 +0000 Subject: 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 --- test/ruby/test_exception.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/ruby/test_exception.rb') diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index 3622cae0d9..da1cbd37cf 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -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 -- cgit v1.2.3