From ed9c67c91ff1e4667c20517e43222cf65328a561 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 24 Mar 2018 10:57:34 +0000 Subject: merge revision(s) 62548,62894: [Backport #14324] eval_error.c: rb_error_write flags * eval_error.c (rb_error_write): add highlight and reverse mode flags. defaulted to rb_stderr_tty_p() if Qnil. error.c: full_message options * error.c (exc_full_message): add highlight: and reverse: keyword options. [Bug #14324] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@62905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_exception.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test') diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index c0631b55f1..62d393a725 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -1132,5 +1132,27 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status| _, err2, status1 = EnvUtil.invoke_ruby(['-e', "#{test_method}; begin; foo; end"], '', true, true) assert_equal(err2, out1) + + e = RuntimeError.new("testerror") + message = e.full_message(highlight: false) + assert_not_match(/\e/, message) + + bt = ["test:100", "test:99", "test:98", "test:1"] + e = assert_raise(RuntimeError) {raise RuntimeError, "testerror", bt} + + message = e.full_message(highlight: false, order: :top) + assert_not_match(/\e/, message) + assert_operator(message.count("\n"), :>, 2) + assert_operator(message, :start_with?, "test:100: testerror (RuntimeError)\n") + assert_operator(message, :end_with?, "test:1\n") + + message = e.full_message(highlight: false, order: :bottom) + assert_not_match(/\e/, message) + assert_operator(message.count("\n"), :>, 2) + assert_operator(message, :start_with?, "Traceback (most recent call last):") + assert_operator(message, :end_with?, "test:100: testerror (RuntimeError)\n") + + message = e.full_message(highlight: true) + assert_match(/\e/, message) end end -- cgit v1.2.3