test(jsonc): make the JSONTestSuite harness compare parsed values - #7303
Open
tomas-zijdemans wants to merge 1 commit into
Open
test(jsonc): make the JSONTestSuite harness compare parsed values#7303tomas-zijdemans wants to merge 1 commit into
tomas-zijdemans wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7303 +/- ##
=======================================
Coverage 95.03% 95.04%
=======================================
Files 617 618 +1
Lines 51637 51640 +3
Branches 9359 9359
=======================================
+ Hits 49075 49080 +5
+ Misses 2021 2019 -2
Partials 541 541 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
The JSONTestSuite harness has never compared a parsed value. This makes it compare them.
getError(() => { JSON.parse(text); })uses a block body with noreturn, sojsonResultandjsoncResultcome backundefinedevery time. TheassertEquals(jsonResult, jsoncResult)on line 47 has been comparingundefinedtoundefinedsince it was written. Thetest_transform/corpus exists for exactly this check (number precision, duplicate keys, NFC/NFD keys, invalid codepoints) and none of it was running.Switching to expression bodies returns the values.
Second fix:
walk()had no extension filter, soREADME.mdandtest.tswere registered as JSON fixtures. Both parsers reject them, so they "passed". Addedexts: [".json"], which is why the count drops from 408 to 406.Does this catch a real bug? No. Everything still passes, so nothing was hiding. To confirm the assertion is live rather than merely present, I sabotaged the jsonc result and watched 159 tests fail, the 159 fixtures that parse successfully under both parsers. That same sabotage passed clean before this change.
No production code touched.
One follow-up I left out on purpose: the harness only checks whether something threw, never the type. That hides two fixtures,
n_structure_100000_opening_arrays.jsonandn_structure_open_array_object.json, where jsonc throwsRangeErrorandJSON.parsethrowsSyntaxError. Asserting the error type means first deciding what jsonc owes on recursion depth, so it gets its own issue rather than riding along here.I used Claude Code to help investigate and write this change.