Testing module

run

procedure · 2 overloadssince 0.28.0Source

Runs body as the subtest name, reported and filtered as test/name. Returns whether it passed.

run :: (t: *Test, name: string, body: (t: *Test)) -> bool

Runs body as the subtest name, reported and filtered as test/name. Returns whether it passed.

Parameters

t: *Test
the parent test.
name: string
the subtest's name.
body: (t: *Test)
the subtest.

Returns

bool
run :: (t: *Test, name: string, body: (t: *Test, data: *$T), data: *T) -> bool

run with data passed on to body, for table tests:

Parameters

t: *Test
the parent test.
name: string
the subtest's name.
body: (t: *Test, data: *$T)
the subtest, called with data.
data: *T
handed to body.

Returns

bool
Example
Case :: struct {
    name: string;
    left: int;
    right: int;
    sum: int;
}

check_case :: (t: *Test, data: *Case) {
    expect_equal(data.left + data.right, data.sum);
}

cases := Case.[.{"small", 1, 2, 3}, .{"large", 40, 2, 42}];
for cases run(t, it.name, check_case, *it);

See also