ruby-changes:56381
From: Nobuyoshi <ko1@a...>
Date: Sun, 7 Jul 2019 18:21:48 +0900 (JST)
Subject: [ruby-changes:56381] Nobuyoshi Nakada: a13636e756 (master): Message to pipe should end with a newline
https://git.ruby-lang.org/ruby.git/commit/?id=a13636e756 From a13636e756662e563e4c4dc802c6fa21cb6d7b52 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sun, 7 Jul 2019 18:17:51 +0900 Subject: Message to pipe should end with a newline diff --git a/parse.y b/parse.y index 7823b42..33f1ef0 100644 --- a/parse.y +++ b/parse.y @@ -5581,7 +5581,7 @@ ruby_show_error_line(VALUE errbuf, const YYLTYPE *yylloc, int lineno, VALUE str) https://github.com/ruby/ruby/blob/trunk/parse.y#L5581 p2 += (lim - ptr); } *p2 = '\0'; - rb_str_catf(mesg, "%s%.*s%s\n""%s%s", + rb_str_catf(mesg, "%s%.*s%s\n""%s%s\n", pre, (int)len, code, post, pre, caret); } diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 75f0896..c356f68 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -13,6 +13,10 @@ class TestParse < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L13 $VERBOSE = @verbose end + def test_error_line + assert_syntax_error('------,,', /\n\z/, 'Message to pipe should end with a newline') + end + def test_else_without_rescue assert_syntax_error(<<-END, %r":#{__LINE__+2}: else without rescue"o, [__FILE__, __LINE__+1]) begin @@ -514,13 +518,13 @@ class TestParse < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L518 mesg = 'from the backslash through the invalid char' e = assert_syntax_error('"\xg1"', /hex escape/) - assert_equal(' ^~', e.message.lines.last, mesg) + assert_equal(' ^~'"\n", e.message.lines.last, mesg) e = assert_syntax_error('"\u{1234"', 'unterminated Unicode escape') - assert_equal(' ^', e.message.lines.last, mesg) + assert_equal(' ^'"\n", e.message.lines.last, mesg) e = assert_syntax_error('"\u{xxxx}"', 'invalid Unicode escape') - assert_equal(' ^', e.message.lines.last, mesg) + assert_equal(' ^'"\n", e.message.lines.last, mesg) e = assert_syntax_error('"\u{xxxx', 'Unicode escape') assert_pattern_list([ @@ -531,14 +535,14 @@ class TestParse < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L535 / \^/, /\n/, /.*: unterminated string.*\n.*\n/, - / \^/, + / \^\n/, ], e.message) e = assert_syntax_error('"\M1"', /escape character syntax/) - assert_equal(' ^~~', e.message.lines.last, mesg) + assert_equal(' ^~~'"\n", e.message.lines.last, mesg) e = assert_syntax_error('"\C1"', /escape character syntax/) - assert_equal(' ^~~', e.message.lines.last, mesg) + assert_equal(' ^~~'"\n", e.message.lines.last, mesg) src = '"\xD0\u{90'"\n""000000000000000000000000" assert_syntax_error(src, /:#{__LINE__}: unterminated/o) @@ -1115,13 +1119,13 @@ x = __ENCODING__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L1119 end def test_unexpected_token_after_numeric - assert_raise_with_message(SyntaxError, /^ \^~~\z/) do + assert_raise_with_message(SyntaxError, /^ \^~~\Z/) do eval('0000xyz') end - assert_raise_with_message(SyntaxError, /^ \^~~\z/) do + assert_raise_with_message(SyntaxError, /^ \^~~\Z/) do eval('1.2i1.1') end - assert_raise_with_message(SyntaxError, /^ \^~\z/) do + assert_raise_with_message(SyntaxError, /^ \^~\Z/) do eval('1.2.3') end end @@ -1171,7 +1175,7 @@ x = __ENCODING__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L1175 end def test_location_of_invalid_token - assert_raise_with_message(SyntaxError, /^ \^~~\z/) do + assert_raise_with_message(SyntaxError, /^ \^~~\Z/) do eval('class xxx end') end end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/