aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_exception.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-22 08:26:23 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-22 08:26:23 +0000
commitb9881083f14f853a208f8e097782cd2a97d61497 (patch)
treeb16a6015d6ddcf5eb83d1905f5938fb90c3db851 /test/ruby/test_exception.rb
parent42f1b589649b78d0a50effb8b16c7bfd5b90e518 (diff)
downloadruby-b9881083f14f853a208f8e097782cd2a97d61497.tar.gz
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/trunk@62894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_exception.rb')
-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 ec4ed03bd2..45dbcca22f 100644
--- a/test/ruby/test_exception.rb
+++ b/test/ruby/test_exception.rb
@@ -1269,5 +1269,27 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
assert_all?(message.lines) do |m|
/\e\[\d[;\d]*m[^\e]*\n/ !~ m
end
+
+ 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