Prints a line to the test's output, which jacket test shows when the test fails.
This one is only checked to compile, not run.
since 0.28.0
#import "Extensions/Testing";
Prints a line to the test's output, which jacket test shows when the test fails.
This one is only checked to compile, not run.
Ends the test as skipped, from the procedure it is written in.
Marks the test as failed and lets it go on.
A directory for this test's files. jacket test creates it and deletes it after a pass
(--keep-temp keeps it); subtests share their test's directory.
Calls callback(data) when the test ends, after its body; the last registered runs first.
Runs body as the subtest name, reported and filtered as test/name. Returns whether it
passed.
expect(1 + 1 == 2);got and want are compared by value: numbers of any width, strings, enums, arrays element
by element (fixed, view and resizable alike) and structs member by member. Strings and arrays
that differ get a diff.
|got - want| <= tolerance. NaN is never near anything.
expect_near(0.5, 0.25, 0.1);This one is meant to fail, so there is nothing to run.
Checks that pointer is null.
Checks that pointer is not null.
The require forms check the same way and, when the check fails, return from the procedure
they are written in (which must return nothing).
expect_equal, then returns from the calling procedure on a failure.
expect_near, then returns from the calling procedure on a failure.
expect_not_null, then returns from the calling procedure on a failure.
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);
}Every member of the enum T, in declaration order, as a list for @cases:
Color :: enum { RED; GREEN; BLUE; }
values := all_values(Color);
assert(values.count == 3);
assert(values[0] == .RED && values[2] == .BLUE);↗The names run_cases gives the subtests of cases: the entry's values, without /, shortened,
repeats numbered. In temporary storage.
Checks value against matcher; a failure is reported at the caller's line. Returns whether
it held.
assert_that(4, greater_than(5));This one is meant to fail, so there is nothing to run.
assert_that, then returns from the procedure it is written in (which must return nothing)
when the check fails.
The message assert_that would report, or an empty string when value matches.
Equal by value, as expect_equal compares; strings, arrays and structs fail with its diff.
Holds when matcher does not.
Every matcher holds.
At least one matcher holds.
Numbers of any width compare by value, strings byte by byte.
The value is at least limit.
The value is less than limit.
The value is at most limit.
low <= value <= high.
|value - want| <= tolerance. NaN is never near anything.
A string holds part as a substring; an array holds part as an element.
A string begins with prefix; an array begins with the elements of the array prefix.
A string ends with suffix; an array ends with the elements of the array suffix.
A string or array with nothing in it.
A string with count bytes or an array with count elements.
An array with an element matcher holds for.
An array whose every element matcher holds for (an empty array qualifies).
The value's type is T exactly; for an Any, the type of what it holds.
Compares the printed form of value with its stored snapshot. Strings are compared as they
are; any other value is printed with one member or element to a line, so a change shows as
a line diff. A test that takes several snapshots numbers them, or names them with name.
Point :: struct { x, y: s32; }
prints_a_point :: (t: *Test) {
expect_snapshot(t, Point.{ 1, 2 });
expect_snapshot(t, "a block of text\nwith two lines", "text");
} @testThis one is only checked to compile, not run.
value as the text a snapshot of it holds.
A generator started from seed.
The next 64 random bits.
A number from 0 to count - 1; 0 when count is 0.
A number from low to high, both included.
True once in one_in calls on average.
A number from 0 up to, not including, 1.
Wraps make as a Custom_Generator for run_property.
Checks the arguments of a property: skips the trial, without failing it, when condition
does not hold. A property that returns a value writes if !condition return true;.
What a @property test runs: body on count generated inputs. Call it by hand to give
the arguments custom generators or another count.
Whether the test that is running is a @compile_time one, run by the compiler now.
Runs cases without benchmarks.
Runs body as a test that prints nothing of its own: a failed check prints its message, and
the program exits with status 1. jacket test runs a doc comment's example with it.
The test that is running. name is parent/child inside a subtest.
The benchmark that is running (bench.jai). A @bench procedure loops iterations times.
What a value should be. Build one with the procedures below; the operands live in temporary storage, so a matcher is for the test that makes it.
A source of pseudo-random numbers (splitmix64). The same seed gives the same numbers on every OS and in every mode, which is what makes a failing run repeatable. Custom generators take one and draw from it.
A generator the property uses for every argument (or part of one) of the type it returns,
in place of the built-in one. Named in a @generate(NAME) note; values it makes are not
shrunk.
even :: (rng: *Rng) -> s64 { return rng_range(rng, -500, 500) * 2; }
doubles :: (n: s64) { expect_equal((n * 3) % 2, 0); } @test @property @generate(even)