Reject the current test case if the condition is false. A rejected test
case is neither a pass nor a failure: it is abandoned, and does not count
toward testCases.
A handle onto the same test case drawing from its own, independent choice stream: give each concurrent task of a test its own clone, so that what one draws does not depend on how the tasks interleave. A clone's draws and notes are printed where the clone was made; use setWorker to label them with the task they came from. Clones share the test case's outcome, so a clone must not be used once the test body has returned: drawing from it then throws.
Draw a value from a generator.
When this test case is reported (the failing example, or every test case
of a verbose run), the generator prints the value as it draws it, as
const draw_1 = <value>;, numbered in the order of the test's draws.
Pass name to report it as const <name>_1 = <value>; instead: each
use of a name is numbered in turn (<name>_1, <name>_2, …). Draws
made while another is
in progress — inside a composite
generator, say — are part of the outer value and are not printed
separately.
The generator must be a generators.PrintableGenerator; a
generator that cannot print throws a TypeError. Use
drawSilent to draw from one without printing it.
Optionalname: stringDraw a value from generator, printing it to printer: how a
generators.PrintableGenerator draws the generators it is built
from, so that each prints in place inside its own output, and inside its
own shrinking span, as drawSilent describes. With
PrettyPrinter.noop it draws silently, from any generator.
Draw a value from a generator without printing it in the report of a failing example. Use it for values that would only clutter the report, or from a generator that cannot print. It cannot be used in an explicit example, whose values are matched to draws by the names they are printed under.
Like every draw, this runs the generator inside a shrinking span
labelled with the generator's label, so a
generator drawing from component generators should draw them through
this (or drawAndPrint) rather than calling their doDraw
directly: that is what groups each component's choices for the shrinker.
Record that label happened in this test case. With the showStatistics
setting on, the end of the run reports the fraction of test cases
recording each event. Has no effect in an explicit example.
Record a numeric observation under label. With the showStatistics
setting on, the end of the run reports the count, minimum, median, mean,
90th percentile and maximum of the values recorded under each label.
value must be finite. Has no effect in an explicit example.
Add a message to the output of this test case, between its drawn values in the order it was recorded. The output is shown for the failing example Hegel reports, and for every test case of a verbose run.
Reject the current test case unconditionally, as assume(false) does.
Run body an engine-chosen number of times, then end the test case
successfully: for workload-style tests that perform operations until the
engine decides to stop. A repetition that rejects (with assume) is
skipped and the next one runs. A failure in any repetition fails the test
case, and shrinking reduces the number of repetitions along with the
values each drew. Each repetition is reported under a // Repetition #N
heading, its draws and notes indented beneath it.
repeat never returns: code after it does not run. For an asynchronous
body, use repeatAsync. In an explicit example, which has no
engine to choose the number of repetitions, body runs once.
repeat with an asynchronous body, each repetition awaited before the next.
Attribute everything this handle prints from now on to concurrent worker
index (a non-negative integer): each line is prefixed with
[worker N +X.XXXms], the time since the test case started.
Guide generation toward test cases that maximise score. label names
the quantity being maximised, so that one test can target several; each
label can be targeted at most once per test case. score must be finite.
Has no effect in an explicit example.
A handle to the current test case, passed to the test function: draw values from it, make assumptions, and record notes, targets and events.