Skip to content

Add initValue1DefaultBranch test case to btree remove module - #1490

Merged
sergey-shandar merged 1 commit into
mainfrom
claude/zen-archimedes-9q2bhq
Aug 11, 2026
Merged

Add initValue1DefaultBranch test case to btree remove module#1490
sergey-shandar merged 1 commit into
mainfrom
claude/zen-archimedes-9q2bhq

Conversation

@sergey-shandar

Copy link
Copy Markdown
Contributor

Summary

Added a new test case to the btree remove module's proof object to verify the default branch behavior of the initValue1 function.

Key Changes

  • Added initValue1DefaultBranch test case that validates initValue1 with a null initial value and a nested array structure containing three elements with separators

Implementation Details

The new test case follows the existing pattern in the proof object and tests the initValue1 function with:

  • A null initial value
  • A complex nested structure: [[['a'], 'b', ['c']], 'd', ['e']]

This complements the existing reduceValue0DefaultBranch test case and ensures comprehensive coverage of default branch scenarios in the btree removal logic.

https://claude.ai/code/session_015FZ8jonsa3mBCwrJaB3FQJ

Exercises the invariant guard the way reduceValue0DefaultBranch already
does for its sibling, raising branch coverage on this module from
95.52% to 97.06%.
@cloudflare-workers-and-pages

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 fb07366 Commit Preview URL

Branch Preview URL
Aug 11 2026, 10:13 AM

@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.

Approving. Reviewed at fb07366. Three lines, and they do exactly what the title says. npx tsc clean, 2357 pass / 0 fail — one more than main's 2356, which is the new case.

The test isn't vacuous

A case under proof.throw passes when its body throws, so the thing worth checking is whether it would still pass if the branch it targets stopped throwing. I mutated initValue1's default arm to return instead:

-            default: { throw 'invalid node' }
+            default: { return [[...n0, v1]] }
before:  proof.throw.initValue1DefaultBranch(): ok  # EXPECTED TO THROW   → 2357 pass, 0 fail
after:   proof.throw.initValue1DefaultBranch(): error                     → 2356 pass, 1 fail

So it genuinely pins the guard. The inputs are right for it too: a === null with n0.length === 3 is the one shape that reaches default, since case 1 and case 2 take the other arms and a non-null a skips the switch entirely.

Not asserting the thrown payload is correct here, per §3's note that whether it threw is normally the part of the contract that matters.

The comment above the proof is the part I'd single out — it explains that these arms are unreachable through the public remove API because the sibling is always a Branch in any reachable tree, which is exactly the question a reader has when they see a guard being exercised directly rather than through the API.

A natural follow-up, not a request

All four merge helpers carry the same guard:

function default: throw 'invalid node' covered
reduceValue0 line 55 yes (pre-existing)
reduceValue2 line 69 no
initValue0 line 83 no
initValue1 line 97 yes (this PR)

This takes the set from 1/4 to 2/4, and the two remaining ones have no proof case anywhere in the repo. The comment already describes all four as a group, so closing the other two would be the same two lines each. Out of scope for a PR that says it covers initValue1 — just flagging it so the gap is visible rather than implied to be closed.

@sergey-shandar
sergey-shandar added this pull request to the merge queue Aug 11, 2026
Merged via the queue into main with commit dff17b0 Aug 11, 2026
19 checks passed
@sergey-shandar
sergey-shandar deleted the claude/zen-archimedes-9q2bhq branch August 11, 2026 14:17
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