diff options
| author | tomoya ishida <tomoyapenguin@gmail.com> | 2025-03-29 20:46:43 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-29 20:46:43 +0900 |
| commit | a4a60195502add094fb52a587411bbd0c19facce (patch) | |
| tree | 6de41bd34a98e01c79318430317a0e1f95f3762f /test | |
| parent | 549c7fe29d95394ccdc4387d24a4c4a48e30dad7 (diff) | |
[Bug #21202] Fix wrong token concat while tokenizing nested unterminated heredoc (#13000)
Notes
Notes:
Merged-By: tompng <tomoyapenguin@gmail.com>
Diffstat (limited to 'test')
| -rw-r--r-- | test/ripper/test_lexer.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/ripper/test_lexer.rb b/test/ripper/test_lexer.rb index a371e8c42d..7a2c22ff2d 100644 --- a/test/ripper/test_lexer.rb +++ b/test/ripper/test_lexer.rb @@ -344,6 +344,47 @@ world" ] assert_lexer(expected, code) + + code = <<~'HEREDOC' + <<H1 + #{<<H2}a + H2 + b + HEREDOC + + expected = [ + [[1, 0], :on_heredoc_beg, "<<H1", state(:EXPR_BEG)], + [[1, 4], :on_nl, "\n", state(:EXPR_BEG)], + [[2, 0], :on_embexpr_beg, "\#{", state(:EXPR_BEG)], + [[2, 2], :on_heredoc_beg, "<<H2", state(:EXPR_BEG)], + [[2, 6], :on_embexpr_end, "}", state(:EXPR_END)], + [[2, 7], :on_tstring_content, "a\n", state(:EXPR_BEG)], + [[3, 0], :on_heredoc_end, "H2\n", state(:EXPR_BEG)], + [[4, 0], :on_tstring_content, "b\n", state(:EXPR_BEG)] + ] + + assert_lexer(expected, code) + + code = <<~'HEREDOC' + <<H1 + #{<<H2}a + H2 + b + c + HEREDOC + + expected = [ + [[1, 0], :on_heredoc_beg, "<<H1", state(:EXPR_BEG)], + [[1, 4], :on_nl, "\n", state(:EXPR_BEG)], + [[2, 0], :on_embexpr_beg, "\#{", state(:EXPR_BEG)], + [[2, 2], :on_heredoc_beg, "<<H2", state(:EXPR_BEG)], + [[2, 6], :on_embexpr_end, "}", state(:EXPR_END)], + [[2, 7], :on_tstring_content, "a\n", state(:EXPR_BEG)], + [[3, 0], :on_heredoc_end, "H2\n", state(:EXPR_BEG)], + [[4, 0], :on_tstring_content, "b\nc\n", state(:EXPR_BEG)] + ] + + assert_lexer(expected, code) end def test_invalid_escape_ctrl_mbchar |
