Commit 40eb461
test(stdlib): batch 1 of algebraic-law property tests (6 cases)
First slice of the proof-obligation catalogue's "ready-this-week" list
— small, no-stdlib-dep semigroup/monoid laws over built-in operators,
asserted through the tree-walking interpreter (the source-level oracle,
backend-independent).
## Cases
| # | Law | Operators |
|---|---|---|
| 1 | `(a ++ b) ++ c = a ++ (b ++ c)` | string `++` associativity |
| 2 | `"" ++ s = s` | string `++` left unit |
| 3 | `s ++ "" = s` | string `++` right unit |
| 4 | `5 / 2 = 2` | int `/` truncates toward zero (positive) |
| 5 | `-5 / 2 = -2` | int `/` truncates toward zero (negative); #478 source-level |
| 6 | `(a + b) + c = a + (b + c)` | int `+` associativity |
Each case compiles a small inline `.affine` source string, runs the
full frontend (parse → resolve → typecheck) + the interpreter, looks
up the law-checker function in the resulting env, applies it with no
args, and asserts the returned `Int` is `0` (convention: zero means
the law held; nonzero is the failing branch's tag).
The interpreter is the right oracle: it executes the AS semantics
directly, so we're testing what every backend must preserve, not just
one backend's lowering. The #478 fix's *codegen* invariant is already
covered by the int_div codegen-deno harness; this case asserts the
*source-level* invariant the codegen must respect.
## Tests run
363 / 363 (was 357 — six new). No flakes. Total runtime delta ≈ 50ms.
## Next batches (catalogue refs)
- Option / Result functor laws (`map(id) = id`, `map(f ∘ g) = map(f) ∘ map(g)`)
- Dict key uniqueness under insert/delete
- Bytes endianness round-trip (`bytes_get_u32_le ∘ bytes_set_u32_le = id`)
- JSON round-trip (`parse ∘ stringify = id` on canonical Json values)
- Hash stability for derived-`Hash` AST types
Stacked on #511 (fix/cicd-foundational-2026-06-01). After #511 merges,
this branch rebases cleanly via patch-equivalent skip on the shared
commits.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent acd44c7 commit 40eb461
2 files changed
Lines changed: 148 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
0 commit comments