aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_parse.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-07-17 00:11:38 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-07-17 00:11:38 +0000
commit0a04e9f42777fc9beb3b866034d6b52a0606ef83 (patch)
tree9509af81484fa953240e12d88fc527b8f6d8e56d /test/ruby/test_parse.rb
parent3ae53aa5f8eb9664690e07857db60b21500fd07d (diff)
downloadruby-0a04e9f42777fc9beb3b866034d6b52a0606ef83.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/ruby/test_parse.rb')
-rw-r--r--test/ruby/test_parse.rb18
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)