Skip to content

Bring asn.1 to 100% line/branch/function coverage: 90.91% → 100% branch - #1596

Merged
sergey-shandar merged 2 commits into
mainfrom
claude/asn1-coverage-improvement
Aug 15, 2026
Merged

Bring asn.1 to 100% line/branch/function coverage: 90.91% → 100% branch#1596
sergey-shandar merged 2 commits into
mainfrom
claude/asn1-coverage-improvement

Conversation

@sergey-shandar

Copy link
Copy Markdown
Contributor

Summary

fjs/asn.1/module.f.mjs was 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 bits 000), 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.
  • Adds tagClass, one check round trip per class×primitive/constructed combination (universal/application/context/private × primitive/constructed), covering all eight.

Test plan

  • npx tsc --noEmit
  • node --test --experimental-test-coverage --test-coverage-include='fjs/asn.1/module.f.mjs' fjs/emergent_testing/all.test.mjs → 100.00% line/branch/func
  • node ./fjs/module.mjs t → 2856 pass, 0 fail

🤖 Generated with Claude Code


Generated by Claude Code

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
@chatgpt-codex-connector

Copy link
Copy Markdown

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
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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 o2alexanderfedin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@sergey-shandar
sergey-shandar added this pull request to the merge queue Aug 15, 2026
Merged via the queue into main with commit f531a9e Aug 15, 2026
19 checks passed
@sergey-shandar
sergey-shandar deleted the claude/asn1-coverage-improvement branch August 16, 2026 03:42
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.

3 participants