test: add nested empty-object list item fixtures#53
Open
montanaflynn wants to merge 1 commit into
Open
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.
Summary
-marker with no trailing space.Rationale
The spec already defines this behavior:
-marker for empty object list items.-at the list-item indentation level.The reference implementation follows that rule recursively.
encodeObjectAsListItemLinesemitsLIST_ITEM_MARKERfor empty objects, whereLIST_ITEM_MARKERis"-"andLIST_ITEM_PREFIXis"- "for non-empty list items:I verified the current reference implementation directly:
decodes back to:
{"items":[[{}],["x",{}]]}Coverage gap
The current fixtures cover empty object list items at the outer list level, for example:
They also cover arrays of empty objects as outer list items. What was missing is the recursive nested-array case:
{"items":[[{}],["x",{}]]}That gap lets an encoder special-case empty objects in top-level expanded arrays while still emitting
-with a trailing space for empty objects inside nested expanded arrays. This PR adds encode and decode coverage for that recursive case.Validation
node --input-type=module -e "JSON.parse(...)"for modified fixture JSONnpx --yes ajv-cli validate -s tests/fixtures.schema.json -d "tests/fixtures/**/*.json"npm run lintnode --experimental-strip-types --input-type=module -e "import { encode, decode } from './packages/toon/src/index.ts'; ..."intoon-format/toonzig build test --summary allinLatentEvals/toon-zig