diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2026-01-28 09:12:51 -0500 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2026-01-28 14:58:55 +0000 |
| commit | 01ace0655ed84708f0afdcc74fb779e680bfc4e0 (patch) | |
| tree | a63b6f791e2b56213a81c16ea282dfcd71e1f1f3 /test | |
| parent | 3b22e32fa50c2c18663be87dad4d11a266954773 (diff) | |
[ruby/prism] Remove tokens from lex compat
Instead of having custom classes, use arrays and track which tokens
we should ignore the state for in the test.
https://github.com/ruby/prism/commit/a333b56ada
Diffstat (limited to 'test')
| -rw-r--r-- | test/prism/ruby/ripper_test.rb | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/test/prism/ruby/ripper_test.rb b/test/prism/ruby/ripper_test.rb index c8d259135f..a89a9503b9 100644 --- a/test/prism/ruby/ripper_test.rb +++ b/test/prism/ruby/ripper_test.rb @@ -136,7 +136,7 @@ module Prism assert_equal(expected, lexer.parse[0].to_a) assert_equal(lexer.parse[0].to_a, lexer.scan[0].to_a) - assert_equal(%i[on_int on_sp on_op], Translation::Ripper::Lexer.new("1 +").lex.map(&:event)) + assert_equal(%i[on_int on_sp on_op], Translation::Ripper::Lexer.new("1 +").lex.map { |token| token[1] }) assert_raise(SyntaxError) { Translation::Ripper::Lexer.new("1 +").lex(raise_errors: true) } end @@ -169,13 +169,13 @@ module Prism # Prism emits tokens by their order in the code, not in parse order ripper.sort_by! { |elem| elem[0] } - [prism.size, ripper.size].max.times do |i| - expected = ripper[i] - actual = prism[i] + [prism.size, ripper.size].max.times do |index| + expected = ripper[index] + actual = prism[index] - # Since tokens related to heredocs are not emitted in the same order, - # the state also doesn't line up. - if expected && actual && expected[1] == :on_heredoc_end && actual[1] == :on_heredoc_end + # There are some tokens that have slightly different state that do not + # effect the parse tree, so they may not match. + if expected && actual && expected[1] == actual[1] && %i[on_comment on_heredoc_end on_embexpr_end on_sp].include?(expected[1]) expected[3] = actual[3] = nil end |
