Repository navigation
test(base): pin the native U32, Nat and Bool ops to Base's defs - #1630
Open
ScottMoore0 wants to merge 1 commit into
Open
ScottMoore0 wants to merge 1 commit into
ScottMoore0 wants to merge 1 commit into
Conversation
U32's arithmetic, bitwise, shift and comparison ops, Nat's ops and
U32.to_nat run as native C and JS (comp.ts OPERATIONS). Each new test's
main prints a list of calls at edge values (0, 1, 2^31-1, 2^31, 2^32-1,
shifts past 31), and its model def proves by {==} that the same calls
equal the printed values in Base's defs. So the test gate checks every
lane against the values and --verdict checks the values against the
model: a native that drifts from its def fails its lane.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The compiler runs U32's arithmetic, bitwise, shift and comparison ops, Nat's ops and
U32.to_natas native C and JS (comp.tsOPERATIONS), not as Base's defs. No test pinned the natives to the defs at edge values. These three tests do:tests/base/u32_native_model.bend: 204 calls ofadd,sub,mul,div,mod,and,or,xor,min,max,inc,shl,shr,not,shln,shrn,powandfrom_nat, at 0, 1, 2^31−1, 2^31, 2^31+1, 2^32−2, 2^32−1, and shifts by 0, 1, 31, 32 and 33.tests/base/u32_native_compare.bend: 40 calls ofis_eq,is_ne,is_lt,is_le,is_gt,is_geandis_zero.tests/base/nat_native_model.bend: 65 calls ofNat'sadd,sub,mul,div,mod,min,max,doubleandpow, plusU32.to_nat.Each has the same shape:
So the test gate checks that every lane prints the values, and
--verdictchecks that the values are what Base's defs compute.What I ran (Linux x86_64 under WSL2,
mainate5527d5):#|lines, and--verdictprints ALL PROOFS CHECK (≤1.1 s each).u32_muldeliberately broken in a copy ofcomp.ts(C+for*, JS+1): the JS and C lanes ofu32_native_model.bendfail. The interpreted lane (which runs Base's defs) and--verdictstill pass.{==}from Base's defs.Not run: the minis (Metal, CUDA). F32 isn't covered, since Base has no model to compare against.
Found and tested with Claude Code, running Claude Opus 5.5, during an audit of
--verdict.