diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2025-02-13 17:50:05 -0800 |
|---|---|---|
| committer | Takashi Kokubun <takashikkbn@gmail.com> | 2025-02-13 17:50:05 -0800 |
| commit | 5ba052675f0eefe77dd7ab30bb9ac186f8d82ccb (patch) | |
| tree | f44d29938c75147dffb5d113cb5142d6ad53eb0e /test | |
| parent | 4bafaef0a55fdc45a7b8275a82ceb0f3e3419d00 (diff) | |
merge revision(s) fb18bb183c24ca82b8f114ed090d62bd69b5df84: [Backport #20989]
[Bug #20989] Ripper: Pass `compile_error`
For the universal parser, `rb_parser_reg_fragment_check` function is
shared between the parser and ripper. However `parser_params` struct
is partially different, and `compile_error` function depends on that
part indirectly.
Diffstat (limited to 'test')
| -rw-r--r-- | test/ripper/test_ripper.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ripper/test_ripper.rb b/test/ripper/test_ripper.rb index 0d3e33dde6..414ce83b7d 100644 --- a/test/ripper/test_ripper.rb +++ b/test/ripper/test_ripper.rb @@ -155,6 +155,18 @@ end end; end + def test_invalid_multibyte_character_in_regexp + lex = Ripper.lex(%q[/#{"\xcd"}/]) + assert_equal([[1, 0], :on_regexp_beg, "/", state(:EXPR_BEG)], lex.shift) + assert_equal([[1, 1], :on_embexpr_beg, "\#{", state(:EXPR_BEG)], lex.shift) + assert_equal([[1, 3], :on_tstring_beg, "\"", state(:EXPR_BEG)], lex.shift) + assert_equal([[1, 4], :on_tstring_content, "\\xcd", state(:EXPR_BEG)], lex.shift) + assert_equal([[1, 8], :on_tstring_end, "\"", state(:EXPR_END)], lex.shift) + assert_equal([[1, 9], :on_embexpr_end, "}", state(:EXPR_END)], lex.shift) + assert_equal([[1, 10], :on_regexp_end, "/", state(:EXPR_BEG)], lex.shift) + assert_empty(lex) + end + def test_no_memory_leak assert_no_memory_leak(%w(-rripper), "", "#{<<~'end;'}", rss: true) 2_000_000.times do @@ -202,4 +214,7 @@ end end end + def state(name) + Ripper::Lexer::State.new(Ripper.const_get(name)) + end end if ripper_test |
