code wiki / (root) / memcap_violation_test.nx

memcap_violation_test.nx source

↩ module page · 17 lines · 560 B

1// memcap_violation_test.nx -- the FAIL path of bounds-check. 2// 3// Exercises memcap_load_i64's assert firing when the load is out 4// of bounds. Paired with memcap.nx's success-path self-test. 5// Expected exit 200 (nx_assert failure). 6// expect_exit: 200 7 8import "nx_syscalls.nx" 9import "nx_memcap.nx" 10 11func main() -> i64 { 12 let c: *MemCap = memcap_alloc(64) 13 // Deliberate out-of-bounds load (offset 64 is one past end). 14 let v: i64 = memcap_load_i64(c, 64) 15 // unreachable: nx_assert exits 200 before we get here 16 return v 17}