Skip to content

test: dual-path suites for keyword contract, single-item SQ, and PN accessors - #540

Merged
awatson1978 merged 1 commit into
release/1.0-beta-corefrom
core/dual-path-bank
Sep 29, 2026
Merged

awatson1978 merged 1 commit into
release/1.0-beta-corefrom
core/dual-path-bank

Conversation

@awatson1978

@awatson1978 awatson1978 commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Three more issue suites land, now that the reading stack is complete. They cover the naturalized keyword contract (test/issues/issue3-keyword-contract.test.js, pinning issues #3/#6/#114/#263), single-item sequence handling (issue218-single-item-sq.test.js, #218/#273), and PersonName accessors (issue231-pn-accessors.test.js, #231/#381/#413). All three are green against the branch as it stands — no engine changes ride along.

These are what I've been calling dual-path suites: the same behavior gets asserted on both roads to a naturalized dataset. The library now has two — the classic buffered path (DicomMessage.readFile followed by DicomMetaDictionary.naturalizeDataset) and the event-stream path (the NaturalizedListener from the previous PR). These files pin the buffered path, and each one's header cross-references the tests in test/eventStream/NaturalizedListener.test.js that pin the identical contract from events, so neither path can drift without a failure.

Using #218 as the example: a sequence with exactly one item used to naturalize to a bare object, which broke generic code like PerFrameFunctionalGroupsSequence[frameNumber - 1]. In 1.0, a single-item sequence stays a length-1 array wrapped in a proxy, so both access styles work — and the suite asserts that with one shared helper:

function expectSingleItemSqContract(seq) {
    expect(Array.isArray(seq)).toBe(true);
    expect(seq.length).toBe(1);
    expect(seq[0].SeriesInstanceUID).toBe(SERIES_UID); // array style (the #218 ask)
    expect(seq.SeriesInstanceUID).toBe(SERIES_UID);    // legacy object style, via the proxy
}

it("ReferencedSeriesSequence with one item supports seq[0].Field and seq.Field", () => {
    const { dataset } = readNaturalized(); // readFile + naturalizeDataset
    expectSingleItemSqContract(dataset.ReferencedSeriesSequence);
});

The event-stream twin ("single-item sequence is the item object, with hidden length 1") runs the same assertions on NaturalizedListener output. The other two suites are just as concrete: keywords come verbatim from the data dictionary, so MappingResource and MappingResourceUID no longer collide and the "UID"/"Sequence" suffixes survive; UID values stay UID strings instead of symbolic names; bulk binary like OverlayData stays binary; no null entries get injected into value arrays (the 0.18.11 defect that ballooned small datasets into 300 MB of JSON); and naturalizing the same dict twice no longer throws on PersonName accessors, whose proxy shape also survives a full write and re-read.

For the bigger picture: these are three of the fourteen issue suites that exercise both the eager and event-stream paths. Of the remaining dual-path suites, two need the writers, so they'll come with the writer wave. The other eight pin engine fixes that haven't landed yet — character-set integration, meta group length, DS/IS precision, implicit private creators, NUL padding, and fragment handling. Each of those arrives in the same PR as its fix, so the branch stays green the whole way.

🤖 Generated with Claude Code

@awatson1978
awatson1978 merged commit a177106 into release/1.0-beta-core Sep 29, 2026
8 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant