Repository navigation
test(downgrader): keep the anyOf of a nullable $ref to a nullable anyOf beside a not - #210
Conversation
…Of beside a `not` A `not` beside a nullable anyOf target can reject null too, so the pair stays an anyOf. No test covered a target with a keyword other than `anyOf` and annotations, so Stryker's `name === 'anyOf'` -> true and `name === 'anyOf' && Array.isArray(...)` -> `||` mutants in admitsNull survived. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VVaw7NSun9amXP2MeQ6Ay3
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- New regression expectation in the nullable-
$refpair suite —owner({ anyOf: [pet, { type: 'null' }], not: { type: 'null' } })now asserts the pair stays{ anyOf: [ref, onlyNull] }. Thenotmakes the$reftarget reject null, soadmitsNullis false andmergeNullablemust keep the explicit null branch rather than collapse to the bare$ref. The expectation is semantically correct.
I verified the mutation coverage claim empirically: both admitsNull mutants (name === 'anyOf' → true, and the && → || guard at packages/downgrader/src/v3.1-to-v3.0.ts:818) make this new assertion fail, and the file passes 122/122 unmutated.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Requested by dinwwwh · project thread
Test-only.
admitsNulllets a nullable$refpair collapse to the bare$refonly when the target holds annotations and ananyOfwith a null branch. No test gave the target another keyword, so two Stryker mutants survived:name === 'anyOf'->true(name === 'anyOf' && Array.isArray(schema.anyOf))->||The new expectation,
anyOf [$ref Pet, null]wherePetis{ anyOf: [pet, null], not: { type: 'null' } }, stays{ anyOf: [ref, onlyNull] }, since thenotcan reject null. Applying each mutant by hand fails this test, and both pass without it. Stryker survivors go from 71 to 69, all equivalent (mergeNullable'sref !== undefined-> true,tagsOf'sgetRef(value) !== undefined-> true).pnpm run checkandpnpm test(367 tests) pass.Generated by Claude Code