Testing module

all_values

procedure · 1 overloadsince 0.30.0Source

Every member of the enum T, in declaration order, as a list for @cases:

ExampleOpen in playground ↗
Color :: enum { RED; GREEN; BLUE; }

values := all_values(Color);

assert(values.count == 3);
assert(values[0] == .RED && values[2] == .BLUE);

Pass it to a test as @cases(all_values(Color)). The array is in temporary storage, so it lasts for the test that asked for it.

all_values :: ($T: Type) -> [] T

Every member of the enum T, in declaration order, as a list for @cases:

Pass it to a test as @cases(all_values(Color)). The array is in temporary storage, so it lasts for the test that asked for it.

Parameters

$T: Type
the enum type.

Returns

[] T
ExampleOpen in playground ↗
Color :: enum { RED; GREEN; BLUE; }

values := all_values(Color);

assert(values.count == 3);
assert(values[0] == .RED && values[2] == .BLUE);

See also