diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-11-11 17:51:31 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-11-22 00:33:19 +0900 |
commit | b7a0ce32da751b437b976b032e73281b9a56b509 (patch) | |
tree | 79f37befe380369ea3e0d0129feb0d390c14c22a /test/ruby | |
parent | 5b959e238e5b7c18d6a1a5f5d9b4b2063de628fe (diff) | |
download | ruby-b7a0ce32da751b437b976b032e73281b9a56b509.tar.gz |
[Bug #19016] `SyntaxError` with parser error messages
Raise a `SyntaxError` with the parser error message, in the case
reading from a file instead of the `-e` option or standard input. So
syntax_suggest can get the message from the caught error.
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_exception.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index 1d3ff6ac18..36f778975b 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -1473,6 +1473,18 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status| end; pattern = /^<detail\.rb>/ assert_in_out_err(%W[-r#{dir}/detail -], "1+", [], pattern) + + File.write(File.join(dir, "main.rb"), "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + 1 + + end; + assert_in_out_err(%W[-r#{dir}/detail #{dir}/main.rb]) do |stdout, stderr,| + assert_empty(stdout) + assert_not_empty(stderr.grep(pattern)) + error, = stderr.grep(/unexpected end-of-input/) + assert_not_nil(error) + assert_match(/<.*unexpected end-of-input.*>/, error) + end end end end |