wcc: @test marker attributes + runner
Hare-style `@test fn check_foo() void = { ... }` now parses. The
attribute is recognised by making the args list optional in
parseattrs: `@symbol("rt_syscall")` still requires the parens;
`@test` doesn't. Same change mirrored in lib/ww/parse/decl.ww.
The runner (test/wcc/910_at_test.c) scans a fixture for
`@test fn IDENT(`, synthesises a wrapper `main()` that calls each
test fn, builds it via `ww run`, and asserts exit 0. A failing
@test would either explicitly call abort or trip a runtime trap
(div-by-zero, etc.) and the whole driver exits non-zero.
The 910_at_test target sits alongside the existing C-side test
binaries; `make test` now runs 20 tests instead of 19.
Fixture: test/wcc/data/attest_pass.ww exercises two passing tests
(simple arithmetic and a match-with-yield).
This commit is contained in:
@@ -1241,9 +1241,13 @@ parseattrs(Parser *p)
|
||||
advance(p);
|
||||
Node *a = newnode(p->a, N_ATTR, pp);
|
||||
a->str = expectident(p);
|
||||
expect(p, TK_LPAREN);
|
||||
a->list = parsearglist(p, TK_RPAREN);
|
||||
expect(p, TK_RPAREN);
|
||||
/* `@name(args...)` for FFI-style attributes;
|
||||
* `@name` (no parens) for marker-only attributes like
|
||||
* `@test`. */
|
||||
if (accept(p, TK_LPAREN)) {
|
||||
a->list = parsearglist(p, TK_RPAREN);
|
||||
expect(p, TK_RPAREN);
|
||||
}
|
||||
if (head == NULL) head = a;
|
||||
else tail->next = a;
|
||||
tail = a;
|
||||
|
||||
Reference in New Issue
Block a user