diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-07-17 00:11:38 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-07-17 00:11:38 +0000 |
commit | 28695a8fff7c04224a58cdb9cb1adeb5810b719c (patch) | |
tree | 9509af81484fa953240e12d88fc527b8f6d8e56d /test | |
parent | b17efb6874345c2dc8dc41f76226463b9a785123 (diff) | |
download | ruby-28695a8fff7c04224a58cdb9cb1adeb5810b719c.tar.gz |
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
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_parse.rb | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 7ce236679c..982f91dc52 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -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) |