diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2024-12-28 11:25:57 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2024-12-28 11:25:57 +0900 |
| commit | fb18bb183c24ca82b8f114ed090d62bd69b5df84 (patch) | |
| tree | c1a34231fbb8d16e8537af5ca9805d7cc72ab0ab /test | |
| parent | 827a19e7781ea2308787f3bb14bfe57b4fcc07f6 (diff) | |
[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.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12482
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 |
