Repository navigation
test(parse-fast): cover the size-dependent and export-prefix branches - #1075
Merged
motdotla merged 1 commit intoOct 16, 2026
Merged
Conversation
Unquoted values locate the comment marker with indexOf below 4096 characters and with a manual scan at or above it, and nothing exercised the larger path. Two neighbouring branches were untested as well: 'export' with no whitespace after it, and a key whose whitespace runs to the end of the input. Every case asserts the fast parser matches the classic one and also pins the expected value, so the two cannot agree by both being wrong. Brings lib/main.js to full statement and branch coverage.
Owner
|
nice contribution! thank you |
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.
parseFastpicks how to locate the comment marker in an unquoted value based on the size of the source:Nothing in the suite reaches the second path, because every fixture and inline case sits well under 4096 characters. Running the suite with coverage enabled showed lines 209-211 of
lib/main.jsnever executing, plus two neighbouring branches: theexportprefix when no whitespace follows it (117-118), and the separator lookahead when whitespace runs to the end of the input (139).Given how many of the recent fixes have been fast-parser consistency bugs, an untested path that only activates on larger
.envfiles seemed worth closing.What this adds
Three tests in
tests/test-parse-fast.js, no source changes:exportwith no whitespace after it.export=1,exports=1andexportFOO=barkeepexportinside the key, whileexport: 1still parses andexport:1is ignored because:requires whitespace.A,A\tandexport Aare ignored without swallowing a neighbouring assignment.Following the convention already in the file, every case asserts that the fast parser matches the classic one and also pins the expected value, so the two cannot pass by both being wrong.
Verification
lib/main.jsgoes from 98.77% statements and 98.24% branches to 100% on both.npm testpasses at 1402 of 1403 with the one pre-existing skip, which covers the build,standard, the d.ts check and the TAP suite.To confirm the tests actually bite, I reverted the behaviour each one describes:
lib/main.js#exportas a prefix without following whitespaceThat last row is the point rather than a gap: making the manual scan handle every size is unobservable, which is exactly the equivalence these tests assert.
For what it is worth, I also ran a differential fuzzer over roughly 630k generated sources comparing
parseagainstparse(src, { fast: true })and found no disagreements, so I have no bug to report here. The fast parser looks solid; this only closes the blind spot in the suite.