wcc: -T test-mode collects @test fns + synthesizes entry, both stages (#15)
@test was parsed then dropped (no consumer); `ww test` needed a hand-written
main listing each test by hand, so adding a @test and forgetting the call
silently skipped it. -T makes the checker collect @test N_FNDECLs in source
order, loud-reject a user main, and append a synthetic
`export fn main() i32 { t0(); ...; return 0; }` at the install->body-check seam;
the existing cgfn emits it (cgen untouched) -> byte-identical by construction.
Mirrors harec's checker-side is_test placement.
Plan-9-lean reduction (user-sanctioned, reinstatable post-CSP): sequential,
abort/nonzero=fail; no setjmp isolation, no fnmatch filter, no file:line.
910/997 rewired from a regex scanner to driving `w6c -T` directly (thin trusted
drivers; the @test content stays ww), with a cross-stage byte-id assert on the
-T output. attest_userman/attest_badsig pin the user-main and bad-signature
rejects.
This commit is contained in:
18
test/wcc/data/attest_badsig.ww
Normal file
18
test/wcc/data/attest_badsig.ww
Normal file
@@ -0,0 +1,18 @@
|
||||
// #15 negative fixture: an @test fn with a non-`fn() void` signature.
|
||||
// The collector must loud-reject (nonzero exit) rather than silently
|
||||
// skip or coerce — rule-7. Pins the signature guard on both stages.
|
||||
//
|
||||
// TEETH: a non-void RETURN with NO params is the case ONLY the explicit
|
||||
// guard catches. The synth entry emits `bad();` (arg count matches 0
|
||||
// params) and a discarded non-void return is silently allowed, so
|
||||
// without the guard this compiles clean (exit 0). A param-bearing @test
|
||||
// would instead trip the checker's independent "not enough arguments"
|
||||
// (check.c:1879) on the synth `bad()` call — so a param fixture would
|
||||
// pass the reject probe whether or not the guard exists, isolating
|
||||
// nothing. Hence the no-param / non-void-return shape.
|
||||
|
||||
package data;
|
||||
|
||||
@test fn bad() i32 = {
|
||||
return 0;
|
||||
};
|
||||
17
test/wcc/data/attest_userman.ww
Normal file
17
test/wcc/data/attest_userman.ww
Normal file
@@ -0,0 +1,17 @@
|
||||
// #15 negative fixture: @test fns PLUS an explicit user `main`. Under
|
||||
// `-T` the entry is synthesized, so a hand-written main collides — both
|
||||
// stages MUST loud-reject (nonzero exit), mirroring harec's hosted-main
|
||||
// suppression under is_test (ref/harec/src/check.c:4000).
|
||||
|
||||
package data;
|
||||
|
||||
@test fn check_ok() void = {
|
||||
let a: i32 = 1;
|
||||
if (a != 1) {
|
||||
let _: i32 = 1 / 0;
|
||||
};
|
||||
};
|
||||
|
||||
export fn main() i32 = {
|
||||
return 0;
|
||||
};
|
||||
Reference in New Issue
Block a user