mirror of
https://github.com/ruby/ruby.git
synced 2025-08-27 15:06:10 +02:00
parse.y: refine literal error messages
* parse.y (parser_yyerror): strip newline in error source which will not be printed, when lex_p has passed it. * parse.y (parser_tokadd_utf8): unterminated Unicode escape even after invalid Unicode escape. * parse.y (parser_parse_string): show the error source line when unterminated literal at end of file. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b17efb6874
commit
28695a8fff
2 changed files with 37 additions and 17 deletions
|
@ -489,11 +489,23 @@ class TestParse < Test::Unit::TestCase
|
|||
e = assert_syntax_error('"\xg1"', /hex escape/)
|
||||
assert_equal(' ^', e.message.lines.last, mesg)
|
||||
|
||||
e = assert_syntax_error('"\u{1234"', 'Unicode escape')
|
||||
assert_match(' ^', e.message.lines.last, mesg)
|
||||
e = assert_syntax_error('"\u{1234"', 'unterminated Unicode escape')
|
||||
assert_equal(' ^', e.message.lines.last, mesg)
|
||||
|
||||
e = assert_syntax_error('"\u{xxxx}"', 'invalid Unicode escape')
|
||||
assert_match(' ^', e.message.lines.last, mesg)
|
||||
assert_equal(' ^', e.message.lines.last, mesg)
|
||||
|
||||
e = assert_syntax_error('"\u{xxxx', 'Unicode escape')
|
||||
assert_pattern_list([
|
||||
/.*: invalid Unicode escape\n.*\n/,
|
||||
/ \^/,
|
||||
/\n/,
|
||||
/.*: unterminated Unicode escape\n.*\n/,
|
||||
/ \^/,
|
||||
/\n/,
|
||||
/.*: unterminated string.*\n.*\n/,
|
||||
/ \^/,
|
||||
], e.message)
|
||||
|
||||
e = assert_syntax_error('"\M1"', /escape character syntax/)
|
||||
assert_equal(' ^~~', e.message.lines.last, mesg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue