diff options
author | Nobuyoshi Nakada <[email protected]> | 2022-11-18 18:22:12 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2022-11-20 20:00:40 +0900 |
commit | 701dfe4eb741628213e4d701c13ad6d76904ac4f (patch) | |
tree | 6ab2acd1b798fa2aedd4d473038ca1cbb2302237 /test/ruby/test_exception.rb | |
parent | 12b7b852272c23d8449af507405ac93cedcb6dd6 (diff) |
[Bug #19016] Handle syntax error in main script like other errors
So that `SyntaxError#detailed_message` will be used also in the case
exiting by such syntax error.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6771
Diffstat (limited to 'test/ruby/test_exception.rb')
-rw-r--r-- | test/ruby/test_exception.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index b87cef3fb6..3a2aeeab80 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -1457,4 +1457,21 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status| assert_match("BOO!", e.full_message.lines.first) assert_equal({ highlight: Exception.to_tty? }, opt_) end + + def test_syntax_error_detailed_message + Tempfile.create(%w[detail .rb]) do |lib| + lib.print "#{<<~"begin;"}\n#{<<~'end;'}" + begin; + class SyntaxError + def detailed_message(**) + Thread.start {}.join + "#{super}\n""<#{File.basename(__FILE__)}>" + end + end + end; + lib.close + pattern = /^<#{Regexp.quote(File.basename(lib.path))}>/ + assert_in_out_err(%W[-r#{lib.path} -], "1+", [], pattern) + end + end end |