test: assert on the lexer's recovery entry point instead of printing it - #6279
Open
prql-bot wants to merge 1 commit into
Open
test: assert on the lexer's recovery entry point instead of printing it#6279prql-bot wants to merge 1 commit into
prql-bot wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
prqlc-parser's lexer tests carried 21eprintln!calls left over from debugging — every one of the crate'seprintln!s lives in that file — and two of them printedlex_source_recovery's output without asserting on it, so the functionprqlc's parser actually calls had no test coverage at all. This drops the printing and replaces it with one test that pins both halves of its return.Found during the nightly survey of
prqlc/prqlc-parser/src/lexer/test.rs.The new test also records something the old printing hid: despite the name,
lex_source_recoverydoesn't resume after an error — it returns(None, errors), not the prefix it had already lexed. Its doc comment said it returns "both the LR and any errors encountered", which is never the case; that's corrected to describe what it does.parse_sourcealready handles theNonecorrectly, so this is a doc fix, not a behavior change. The test is also the only coverage for thesource_idparameter, the one thing that distinguishes it fromlex_source— hence the1:prefix on the asserted span, wherelex_sourcehard-codes0:.The rest of the cleanup
insta::assert_debug_snapshotinside the function body, shadowing the file-level import on line 2.super::lex_sourcewhile the rest of the file used the importedlex_source.test_issue_triple_quoted_with_double_quotereferred to "the specific test case from ISSUE.md". NoISSUE.mdexists in the tree, andgit log --all -- ISSUE.mdfinds no commit that ever added one, so the comment now describes the case itself: a triple-quoted body containing both quote characters, where the lone"is content.test_single_curly_quoteandtest_interpolation_emptysaid what the test was for at the time it was written ("Test what error we get", "the case that's showing a changed error position") rather than what it pins; they now name the asserted behavior — a character-, not byte-, indexed span, and an unterminated f-string reporting at end of input.No assertion was changed or removed: the two tests that lost their
lex_source_recoverycalls keep theirlex_sourcesnapshots exactly as they were.Verification