diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-05-30 22:03:33 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-05-30 22:03:33 +0900 |
commit | 92ecf58b1e8ed15f5ec2bf69e3871de4343f71e0 (patch) | |
tree | 79ae69f7500e843157c573437ebeb212d5b51ca1 /test | |
parent | b0e2b7a5ff0df14b3c8062c31ebb526a73a03763 (diff) |
parse.y: adjust here-doc error token
* parse.y (here_document): adjust token to the here-doc identifier
in compile_error when a here-document misses the closing
identifier.
Diffstat (limited to 'test')
-rw-r--r-- | test/ripper/test_lexer.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/test/ripper/test_lexer.rb b/test/ripper/test_lexer.rb index 4b70915851..c8cc512a33 100644 --- a/test/ripper/test_lexer.rb +++ b/test/ripper/test_lexer.rb @@ -120,17 +120,21 @@ class TestRipper::Lexer < Test::Unit::TestCase message = proc {result.pretty_inspect} expected = [ [[1, 0], :on_heredoc_beg, "<<A", state(:EXPR_BEG)], + [[1, 2], :compile_error, "A", state(:EXPR_BEG), "can't find string \"A\" anywhere before EOF"], [[1, 3], :on_period, ".", state(:EXPR_DOT)], [[1, 4], :on_ident, "upcase", state(:EXPR_ARG)], [[1, 10], :on_nl, "\n", state(:EXPR_BEG)], - [[1, 11], :compile_error, "", state(:EXPR_BEG), "can't find string \"A\" anywhere before EOF"], ] pos = 0 expected.each_with_index do |ex, i| s = result[i] assert_equal ex, s.to_a, message - assert_equal pos, s.pos[1], message - pos += s.tok.bytesize + if pos > s.pos[1] + assert_equal pos, s.pos[1] + s.tok.bytesize, message + else + assert_equal pos, s.pos[1], message + pos += s.tok.bytesize + end end assert_equal pos, code.bytesize assert_equal expected.size, result.size |