Test LibStringSet.holds membership directly - #175
thedavidmeister wants to merge 4 commits into
Conversation
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V8ViHcKLVk2YoS2joH4HdN
holds had no test of its own. Its only exercise was indirect, through the snapshot shape and build tests, which never present two distinct strings of the same length to it and never present an empty list or an empty needle. Adds a unit test for membership as the NatSpec defines it: whole content equality by value over a list whose order does not matter, an empty list holding nothing, and the empty string held only when an element is itself empty. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V8ViHcKLVk2YoS2joH4HdN
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. WalkthroughThe pull request adds comprehensive tests for ChangesString-set membership validation
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~15 minutes Change: Other Merge Risk: ⚪ Minimal · up to The added coverage does not introduce a current merge-blocking risk. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
mutants.toml is harness input for the mutation sweep, not part of the repository, and an unlicensed file fails the REUSE check. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V8ViHcKLVk2YoS2joH4HdN
|
Closing unmerged: its subject is gone. LibStringSet was deleted from this repo in #210, which replaced all sixteen call sites with LibMemoryKV. The membership behaviours these tests pinned are now covered by that library's own suite, and the five gaps they closed are moot because the loop they covered no longer exists here. |
What
Adds
test/src/lib/LibStringSet.t.sol, a unit test forLibStringSet.holds.No source change.
Why
holdshad no test of its own. Its only exercise was indirect, throughGeneratedSnapshotShapeTestandBuildTest, which pass it real contract andrelease names. Those names never collide in length without also colliding in
content, and the lists are never empty, so a large part of what the NatSpec
claims was asserted nowhere: that equality is over the whole content rather
than the length or a prefix of it, that an empty list holds nothing, and that
the empty string is an ordinary member, held only when an element is itself
empty.
The NatSpec is the oracle. It says membership over a
string[]for a set whoseorder it does not fix, compared over the whole string. Each test states one case
of that definition, with the answer derived from the definition rather than from
the loop that implements it.
QA
Mutation matrix over
src/lib/LibStringSet.sol. Suite isforge testminus the61 fork tests that need RPC env vars absent on the machine this ran on.
LibStringSetis not compiled intoAddressRegistryorMigrationRegistry, sothe pinned address and code hash tests carry real behaviour for it and were kept
in rather than excluded. Baseline before: 397 passed, 0 failed. Baseline after:
409 passed, 0 failed. Every mutant below was applied to the unmutated source one
at a time and the whole suite run against it.
Before the new file, 6 of 11 mutants were killed by pre-existing indirect tests
and 5 survived. After it, 11 of 11 are killed.
return trueinside the loop becomesreturn falsereturn falsebecomesreturn truereturn falsebecomesreturn haystack.length == 0i = 1i + 1 < haystack.lengthreturn truewhen the needle is emptyNo bug was found in
holds. Every surviving mutant was a test gap: the currentoutput is the one the NatSpec calls for in each case.
🤖 Generated with Claude Code
https://claude.ai/code/session_01V8ViHcKLVk2YoS2joH4HdN
Summary by CodeRabbit