Since TurfLang 2.2.
A function marked @test is run by turf test, one test at a time, and every build leaves it out of the program. So nothing else may call it, or use it as a function value:
Example
@testfn parses_a_port(): void { test::assert(parse_port("8080") == 8080, "8080 is a port");}fn main(): int { parses_a_port(); // ERROR: I cannot use the test `parses_a_port` return 0;}If the test and the program need the same steps, move them into an ordinary function and call that from both:
Example
fn check_port(): bool { return parse_port("8080") == 8080;}@testfn parses_a_port(): void { test::assert(check_port(), "8080 is a port");}fn main(): int { if check_port() { return 0; } return 1;}To run a test, use turf test.
Run turf --explain E173 in a terminal to read this again.