Skip to content

Commit 9527bb6

Browse files
authored
Merge pull request #3408 from Earlopain/parser-translator-token-compare
Be a bit stricter when comparing parser translator tokens
2 parents 31009d8 + e9e9a48 commit 9527bb6

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

test/prism/ruby/parser_test.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,14 @@ def assert_equal_asts_message(expected_ast, actual_ast)
207207

208208
def assert_equal_tokens(expected_tokens, actual_tokens)
209209
if expected_tokens != actual_tokens
210-
expected_index = 0
211-
actual_index = 0
210+
index = 0
211+
max_index = [expected_tokens, actual_tokens].map(&:size).max
212212

213-
while expected_index < expected_tokens.length
214-
expected_token = expected_tokens[expected_index]
215-
actual_token = actual_tokens.fetch(actual_index, [])
213+
while index <= max_index
214+
expected_token = expected_tokens.fetch(index, [])
215+
actual_token = actual_tokens.fetch(index, [])
216216

217-
expected_index += 1
218-
actual_index += 1
217+
index += 1
219218

220219
# There are a lot of tokens that have very specific meaning according
221220
# to the context of the parser. We don't expose that information in

0 commit comments

Comments
 (0)