diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-08-11 22:24:47 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-08-12 15:58:18 +0900 |
commit | 844a0edbae6e74293e3d0cb1ceeeb66a4371d06d (patch) | |
tree | 7e1652945a9a290633476d2dd8b09e5e8fa69025 /test/ripper/test_lexer.rb | |
parent | 803a07263001e5466bba0f53fcc85784f4b5c686 (diff) | |
download | ruby-844a0edbae6e74293e3d0cb1ceeeb66a4371d06d.tar.gz |
[Bug #18962] Do not read again once reached EOF
`Ripper::Lexer#parse` re-parses the source code with syntax errors
when `raise_errors: false`.
Co-Authored-By: tompng <tomoyapenguin@gmail.com>
Diffstat (limited to 'test/ripper/test_lexer.rb')
-rw-r--r-- | test/ripper/test_lexer.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ripper/test_lexer.rb b/test/ripper/test_lexer.rb index 83130668be..4f3f4657ef 100644 --- a/test/ripper/test_lexer.rb +++ b/test/ripper/test_lexer.rb @@ -100,6 +100,20 @@ class TestRipper::Lexer < Test::Unit::TestCase assert_equal expect, Ripper.lex(src).map {|e| e[1]} end + def test_end_of_script_char + all_assertions do |all| + ["a", %w"[a ]", %w"{, }", "if"].each do |src, append| + expected = Ripper.lex(src).map {|e| e[1]} + ["\0b", "\4b", "\32b"].each do |eof| + c = "#{src}#{eof}#{append}" + all.for(c) do + assert_equal expected, Ripper.lex(c).map {|e| e[1]} + end + end + end + end + end + def test_slice assert_equal "string\#{nil}\n", Ripper.slice(%(<<HERE\nstring\#{nil}\nHERE), "heredoc_beg .*? nl $(.*?) heredoc_end", 1) |