code wiki / _hdl_build / nx_triangulate_test.nx
nx_triangulate_test.nx
buildroot/runtime/_hdl_build/nx_triangulate_test.nx
about
nx_triangulate_test.nx -- VALIDATES the reusable triangulation harness
(nx_triangulate.nx) itself: proves it PASSES three agreeing legs and CATCHES a
deliberately-wrong leg. A harness that only ever says "pass" is worthless; this
test proves the catch path fires, so the harness can be trusted to gate real
capabilities (Cardinal 7 test before ship; Cardinal 25 build intelligence).
We exercise the harness on a REAL capability (integer division) using three
genuinely independent legs over a battery, exactly as the divider proof does:
LEG A -- Newton-Raphson reciprocal divide (the multiplicative frontier)
LEG B -- restoring shift-subtract divide (independent algorithm)
LEG C -- behavioral `/` (oracle is C; A,B are the legs judged against it)
Then we run two adversarial scenarios THROUGH the harness:
(1) all three legs correct -> harness must report PASS, all-agree.
(2) one leg deliberately corrupted (off-by-one) -> harness must report a
CAUGHT failure, naming the bad leg index + its wrong value.
KNOWN ANSWER (FAIL LOUD), one line:
"<good_passed> <good_total> <caught> <bad_leg> <bad_got> <bad_exp> <argguard>"
good_passed == good_total (clean battery: every vector triangulates)
caught == 1 (the corrupted leg WAS detected, not swallowed)
bad_leg, bad_got, bad_exp (the 5W1H diagnostic the harness surfaced)
argguard == 1 (boundary guard rejects a malformed request)
Any deviation -> nonzero exit. Expected: "65536 65536 1 1 36 35 1 " run=0
dependencies 1 imports · 0 importers
imports: nx_triangulate.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 27 | const TW_W: i64 = 16 |
| 28 | const TW_F: i64 = 65536 |
| 29 | const TW_FF: i64 = 4294967296 |
| 30 | const TW_ITERS: i64 = 3 |
functions
| 32 | func _emit_num(v: i64) -> i64 called by 1: main |
| 40 | func _nl() -> i64 { let z: *u8 = sys_mmap(2); z[0] = 10; sys_write(1, z, 1); return 0 } called by 1: main |
| 43 | func tw_msb_pos(d: i64) -> i64 called by 1: tw_newton |
| 50 | func tw_newton(N: i64, D: i64) -> i64 |
| 69 | func tw_restoring(N: i64, D: i64) -> i64 called by 1: main |
| 81 | func main() -> i64 |