package b0
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha512=e9aa779e66c08fc763019f16d4706f465d16c05d6400b58fbd0313317ef33ddea51952e2b058db28e65f7ddb7012f328c8bf02d8f1da17bb543348541a2587f0
doc/b0.std/B0_testing/Test/T/index.html
Module Test.T
Source
Testers.
A tester simply packs an equality function and a formatter to print values.
Important. We indicate when the printers respect the OCaml syntax. Only these testers are suitable for use with Test.snap
.
Testers
make ~equal ~pp ()
is a tester using equal
to assert values and pp
to inspect them. Note the following points:
- If your module
M
implementT
it can directly be used as an equality tester value as(module M)
, you don't need to call this function. - If you want to use
M
withTest.snap
note that it expectsM.pp
to output valid OCaml syntax. If that is not the case you can redefine it withwith_tester
. - By convention the first argument of
equal
is the value to test and the second value is the reference value. This is somtimes used by the combinators.
pp t
is the formatting function of t
.
with' t
is t
with those arguments specified replaced.
Predefined testers
Generic
true'
equates all values and prints them with Test.Fmt.anon
.
false'
distinguishes all values and prints them with Test.Fmt.anon
.
any
uses Stdlib.compare
for testing equality (works Float.nan
values) and prints them with Test.Fmt.anon
.
Exceptions
exn
uses Stdlib.compare
for testing equality and prints with B0_std.Fmt.exn
.
invalid_arg
has an equality function that returns true
iff the first argument is of the form Invalid_argument _
.
failure
has an equality function that returns true
iff the first argument is of the form Failure _
.
Base types
bool
tests booleans and prints them as OCaml syntax with B0_std.Fmt.Lit.bool
.
int32
tests 32-bit integers and prints them as OCaml syntax with B0_std.Fmt.Lit.int32
.
uint32
tests unsigned 32-bit integers and prints them with B0_std.Fmt.Lit.uint32
int64
tests 64-bit integers and prints them as OCaml syntax with B0_std.Fmt.Lit.int64
.
uint64
tests unsigned 64-bit integers and prints them as OCaml syntax with B0_std.Fmt.Lit.uint64
.
nativeint
tests native integers and prints them as OCaml syntax with Fmt.Lit.nativeint
.
nativeuint
tests unsigned native integers and prints them as OCaml syntax with B0_std.Fmt.Lit.nativeuint
.
float
tests float with Float.equal
so it can be used to assert nan
values and prints as OCaml syntax them with B0_std.Fmt.Lit.floatl
.
Warning. Be aware of the limitations of testing floats for strict binary equality.
hex_float
is like float
but uses the OCaml syntax B0_std.Fmt.Lit.hex_float
for printing.
Characters and strings
char
tests characters (bytes) and prints them as OCaml syntax with B0_std.Fmt.Lit.char
.
ascii_string
tests strings and prints them as OCaml syntax with B0_std.Fmt.Lit.ascii_string
.
string
tests strings and prints them as OCaml syntax with B0_std.Fmt.Lit.string
binary_string
tests strings and prints them with as OCaml syntax with B0_std.Fmt.Lit.binary_string
.
styled_string
tests strings and prints them with with B0_std.Fmt.styled_text_string
.
lines
tests strings and prints them by lines using B0_std.Fmt.lines
.
bytes
tests bytes and prints them with B0_std.Fmt.bytes
.
Parametric types
option v
tests options of values tested with v
and prints them as OCaml syntax with B0_std.Fmt.Lit.option
.
either ~left ~right
tests Either.t
values and prints them as OCaml syntax with B0_std.Fmt.Lit.either
.
result ok
tests result values using ok
for Ok
and a string
for Error
and prints them as OCaml syntax with B0_std.Fmt.Lit.result
.
result ok error
tests result values using the given equalities for the values of each cas and prints them as OCaml syntax with B0_std.Fmt.Lit.result
.
list elt
tests list of elements tested with elt
and prints them as OCaml syntax with B0_std.Fmt.Lit.list
.
array elt
test array of elements tested with elt
and prints them as OCaml syntax with B0_std.Fmt.Lit.array
.
pair fst snd
tests pairs with fst
and snd
and prints them as OCaml syntax with B0_std.Fmt.Lit.pair
.
t3
tests triplets and prints them as OCaml syntax with B0_std.Fmt.List.t3
.
t4
tests quadruplets and prints them as OCaml syntax with B0_std.Fmt.List.t4
.
t5
tests quintuplets and prints them as OCaml syntax with B0_std.Fmt.List.t5
.