Skip to content

test: add nested empty-object list item fixtures#53

Open
montanaflynn wants to merge 1 commit into
toon-format:mainfrom
montanaflynn:test-nested-empty-object-list-item
Open

test: add nested empty-object list item fixtures#53
montanaflynn wants to merge 1 commit into
toon-format:mainfrom
montanaflynn:test-nested-empty-object-list-item

Conversation

@montanaflynn
Copy link
Copy Markdown

Summary

  • Add encode/decode fixtures for nested expanded arrays containing empty object list items.
  • Confirm recursive empty-object list items encode as a bare - marker with no trailing space.
  • Record the fixture addition in the changelog.

Rationale

The spec already defines this behavior:

  • §9.4 says expanded list items may use a bare - marker for empty object list items.
  • §10 says an empty object list item is a single - at the list-item indentation level.
  • §12 says encoders MUST NOT emit trailing spaces.

The reference implementation follows that rule recursively. encodeObjectAsListItemLines emits LIST_ITEM_MARKER for empty objects, where LIST_ITEM_MARKER is "-" and LIST_ITEM_PREFIX is "- " for non-empty list items:

I verified the current reference implementation directly:

items[2]:
  - [1]:
    -
  - [2]:
    - x
    -

decodes back to:

{"items":[[{}],["x",{}]]}

Coverage gap

The current fixtures cover empty object list items at the outer list level, for example:

items[3]:
  - first
  - second
  -

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 JSON
  • npx --yes ajv-cli validate -s tests/fixtures.schema.json -d "tests/fixtures/**/*.json"
  • npm run lint
  • node --experimental-strip-types --input-type=module -e "import { encode, decode } from './packages/toon/src/index.ts'; ..." in toon-format/toon
  • zig build test --summary all in LatentEvals/toon-zig

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.

1 participant