Bring asn.1 to 100% line/branch/function coverage: 90.91% → 100% branch - #1596
Conversation
90.91% branch coverage (6 uncovered branches): parsedTagDecode narrows a tag's class+P/C bits to one of eight values via an 8-way `||` assert, but every existing test only ever decoded a universal-primitive tag (top bits 000), so the other seven comparisons never had a case where they were the one that turned the assert true. Adds tagClass, one round trip per class×primitive/constructed combination, covering all eight. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BmWCv5YGRXToq26xPoSXjX
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BmWCv5YGRXToq26xPoSXjX
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
functionalscript | 15f7037 | Commit Preview URL Branch Preview URL |
Aug 15 2026, 09:57 PM |
o2alexanderfedin
left a comment
There was a problem hiding this comment.
Measured both ends rather than taking the numbers from the body: origin/main → line 100.00 / branch 90.91 / funcs 100.00; this head → 100.00 / 100.00 / 100.00.
The stated cause is accurate — fjs/asn.1/module.f.mjs:72-75 is exactly the 8-way || assert over firstByte & 0b111_00000n, which came in with #1589 replacing a compile-time cast with a runtime narrowing assert. All eight tag constants are right per X.690 (0x02/0x22 universal P/C, 0x42/0x62 application, 0x82/0xA2 context, 0xC2/0xE2 private), and the low 5 bits 00010 stay under tagNumberMask so no long-form path is taken by accident.
The important part for a coverage PR: these assert rather than merely execute. check compares the decoded tag against the caller's literal, not against implementation output. Confirmed by mutation — changing classPcMask to 0b011_00000n made exactly the four bit-8-set cases fail (2852 pass / 4 fail), so the new cases can actually fail.
Co-located proof.f.mjs under export const proof, reusing the file's existing check helper, all eight as individually named tests. npx tsc exit 0; fjs test → 2856 pass / 0 fail. Changelog conforms, with #1571/#1576 as precedent for shipping an entry on a proof-only PR.
Summary
fjs/asn.1/module.f.mjswas at 90.91% branch coverage (6 uncovered branches). This brings it to 100% line/branch/function coverage:parsedTagDecode's 8-way||assert narrows a decoded tag's class + primitive/constructed bits (top 3 bits of the first byte) to one of exactly eight values. Every existing test in this file only ever decoded a universal-primitive tag (top bits000), so the other seven===comparisons in the chain never had a case where they were the one making the assert true — they were always short-circuited past.tagClass, onecheckround trip per class×primitive/constructed combination (universal/application/context/private × primitive/constructed), covering all eight.Test plan
npx tsc --noEmitnode --test --experimental-test-coverage --test-coverage-include='fjs/asn.1/module.f.mjs' fjs/emergent_testing/all.test.mjs→ 100.00% line/branch/funcnode ./fjs/module.mjs t→ 2856 pass, 0 fail🤖 Generated with Claude Code
Generated by Claude Code