Runs body once per entry of cases, each as the subtest test/<values>; returns whether
every case passed. An entry is the argument of body, or, when body takes several, a struct
whose members are its arguments in order. body may take a leading *Test. This is what a
@test procedure with a @cases(LIST) note runs; call it by hand to build the list at run
time or to run a helper per case:
Case :: struct { input: string; length: s64; }
checks_each_case :: (t: *Test) {
lengths :: (input: string, length: s64) {
expect_equal(input.count, length);
}
passed := run_cases(t, Case.[.{ "", 0 }, .{ "abc", 3 }], lengths);
expect(passed);
}- t: the running test.
- cases: the entries to run, one subtest each.
- $body: the procedure each entry is passed to.
run_cases :: (t: *Test, cases: [] $T, $body: $B) -> bool
Runs body once per entry of cases, each as the subtest test/<values>; returns whether
every case passed. An entry is the argument of body, or, when body takes several, a struct
whose members are its arguments in order. body may take a leading *Test. This is what a
@test procedure with a @cases(LIST) note runs; call it by hand to build the list at run
time or to run a helper per case:
Parameters
- t: *Test
- the running test.
- cases: [] $T
- the entries to run, one subtest each.
- $body: $B
- the procedure each entry is passed to.
Returns
- bool
Case :: struct { input: string; length: s64; }
checks_each_case :: (t: *Test) {
lengths :: (input: string, length: s64) {
expect_equal(input.count, length);
}
passed := run_cases(t, Case.[.{ "", 0 }, .{ "abc", 3 }], lengths);
expect(passed);
}