code wiki / _hdl_build / nx_uiq_contrast_gate.nx

nx_uiq_contrast_gate.nx source

↩ module page · 18 lines · 1017 B

1// nx_uiq_contrast_gate.nx -- KAT gate for the computed WCAG contrast auditor. 2// Proves (before any page is judged): the WCAG math matches the W3C reference (21.00 / 4.54), the CSS color 3// parser handles rgb()/hex, the audit is NON-VACUOUS (catches a real #999-on-#fff = 2.85:1 fail), and it does 4// NOT false-positive on a page with no color tokens. Deterministic sovereign gate (nx_cc->nxasm). 5// license_tier: ORIGINAL expect_exit: 0 6import "nx_uiq_color.nx" 7 8func main() -> i64 { 9 uiq_w("=== nx_uiq_contrast_gate -- computed WCAG 2.x contrast ===\n" as *u8) 10 let f: i64 = uiq_selftest() 11 uiq_w("selftest checks failed=" as *u8); uiq_pn(f); uiq_w("\n" as *u8) 12 uiq_w("demo audit (--mut #999 on --bg #fff): " as *u8) 13 let fbx: *u8 = ":root{--mut:#999;--bg:#fff}" as *u8 14 var fbn: i64=0; while fbx[fbn]!=(0 as u8) { fbn=fbn+1 } 15 uiq_audit_buf(fbx,fbn,1) 16 if f==0 { uiq_w("VERDICT=verdict=GREEN\n" as *u8); sys_exit(0); return 0 } 17 uiq_w("VERDICT=RED\n" as *u8); sys_exit(1); return 1 18}