Skip to content

Be a bit stricter when comparing parser translator tokens#3408

Merged
kddnewton merged 1 commit intoruby:mainfrom
Earlopain:parser-translator-token-compare
Jan 14, 2025
Merged

Be a bit stricter when comparing parser translator tokens#3408
kddnewton merged 1 commit intoruby:mainfrom
Earlopain:parser-translator-token-compare

Conversation

@Earlopain
Copy link
Collaborator

Now it's possible to receive an assertion like this:

expected: []
actual: [:tNL, [nil, #<Parser::Source::Range comment_single.txt 8...9>]]
<[]> expected but was
<[:tNL, [nil, #<Parser::Source::Range comment_single.txt 8...9>]]>

All tests pass so it's no big deal but in #3399 I almost introduced a different bug where this check would then have failed like this instead of silently passing.

When there were more actual tokens than expected tokens, the test would still pass.

Now it's possible to receive an assertion like this:
```
expected: []
actual: [:tNL, [nil, #<Parser::Source::Range comment_single.txt 8...9>]]
<[]> expected but was
<[:tNL, [nil, #<Parser::Source::Range comment_single.txt 8...9>]]>
```
Copy link
Collaborator

@kddnewton kddnewton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't wait to have assert_equal expected_tokens, actual_tokens.

@kddnewton kddnewton merged commit 9527bb6 into ruby:main Jan 14, 2025
57 checks passed
@Earlopain Earlopain deleted the parser-translator-token-compare branch January 16, 2025 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants