Page
Library
Module
Module type
Parameter
Class
Class type
Source
Popper
SourcePopper is an OCaml testing library that can be used for writing simple unit-tests as well as property-based ones. Its underlying design is inspired by the Python library Hypothesis.
test ?config f
creates a test that when run evaluates f
that produces a Proposition.t Sample.t
value. If the the sample consumes any input, it is run a number of times until it either finds some input value that causes the sample to yield a failing proposition, or until it passes specified number of runs (default is 300). If config
is given it takes all the specified overrides into account.
suite ts
packs the list of name and test pairs, ts
, into a single test suite.
pass
is a sample that always returns the value pass
.
fail ?loc msg
is a sample that returns the value fail
with location loc
if given and error message msg
.
equal ?loc cmp x y
is a sample that returns a proposition that is pass
only if x
and y
are equal using the given comparator cmp
. If loc
is passed, it reports the location string in case of failure.
less_than ?loc cmp x y
is a sample that returns a proposition that is pass
only if x
is less than y
, using the given comparator cmp
. If loc
is passed, it reports the location string in case of failure.
greater_than?loc cmp x y
is a sample that returns a proposition that is pass
only if x
is greater than y
, using the given comparator cmp
. If loc
is passed, it reports the location string in case of failure.
less_than_equal ?loc cmp x y
is a sample that returns a proposition that is pass
only if x
is less than or equal to y
, using the given comparator cmp
. If loc
is passed, it reports the location string in case of failure.
is_true ?loc b
is a sample that returns a proposition that is pass
only if b
is true. If loc
is passed, it reports the location string in case of failure.
is_false ?loc b
is a sample that returns a proposition that is pass
only if b
is false. If loc
is passed, it reports the location string in case of failure.
all ps
combines a list of proposition samples into a sample that only returns pass in case all returned propositions pass.
any ps
combines a list of proposition samples into a single sample that returns pass in case any of the returned propositions pass.
check ?config f
runs a single anonymous test using the config
settings if given. In case the test fails, an exception of type Test_failure
is raised.