summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-24 10:57:34 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-24 10:57:34 +0000
commited9c67c91ff1e4667c20517e43222cf65328a561 (patch)
tree9813a5f21059a4d18664cd12b89c8ba4a4b103ba /test
parentc40df5a76941d3a8c2cff46432b23401b6ffffbc (diff)
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
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_exception.rb22
1 files changed, 22 insertions, 0 deletions
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