package octez-libs
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
doc/octez-libs.test-helpers/Tezos_test_helpers/Assert/index.html
Module Tezos_test_helpers.Assert
Source
module Assert
contains Alcotest convenience assertions.
Type definitions
An assertion that a relation between two elements of 'ty
holds true. This assertion returns a value of type 'res
when it succeeds, typically unit
, as in check2
. *
Alias for t
used in EQUALITIES
.
A 'a check2
is an assertion over two elements of type 'a
returning unit when it holds.
type ('base_ty, 'container_ty) equality_check =
?eq:('base_ty -> 'base_ty -> bool) ->
?pp:(Format.formatter -> 'base_ty -> unit) ->
'container_ty check2
An equality_check
is an assertion that the boolean relation defined by eq
holds on two series -- of type 'container_ty
-- of elements of 'base_ty
,
This typically defines the type of assertions on lists (see equal_list
), or arrays, but it is also used to defined new checks based on an equality function.
type ('base_ty, 'container_ty) comparison_check =
?cmp:('base_ty -> 'base_ty -> int) ->
?pp:(Format.formatter -> 'base_ty -> unit) ->
'container_ty check2
A comparison_check
is similar to a equality_check
except the assertion is based on the optional comparison function cmp
.
Base definitions
Failures
fail ?loc ?msg pp x y
fails after printing message "<loc> <msg>: expected <x> got <y>".
- when
msg
is omitted "<msg:> " is not printed - when
loc
is omitted "<loc> " is not printed
fail_msg fmt
fails after pretty-printing fmt
Assertions based on (un)equalities
equal ?eq ?pp ?msg ?loc a b
checks that eq a b
and if not calls fail pp a b msg loc
unequal ?eq ?pp ?msg ?loc a b
checks that eq a b
does not hold. See equal
for the rest of the documentation.
equal_list ?eq ?pp ?msg ?loc l1 l2
is like equal
but for polymorphic lists 'a list
.
equal_list_list
is like equal
but for polymorphic lists of lists 'a list list
.
Assertions based on comparisons
leq ?cmp ?pp ?loc ?msg a b
checks that cmp a b <= 0
.
lt ?cmp ?pp ?loc ?msg a b
checks that cmp a b < 0
.
See leq
for details of the parameters.
geq ?cmp ?pp ?loc ?msg a b
checks that cmp a b >= 0
.
See leq
for details of the parameters.
gt ?cmp ?pp ?loc ?msg a b
checks that cmp a b > 0
.
See leq
for details of the parameters.
Miscellaneous assertions
Alcotest check that b
is true
.
Alcotest check that b
is false
.
Alcotest version of assert false
.
Assert that at least one value in l
satisfies f
.
contains m msg x ls
asserts that one testable in ls
equals x
, and otherwise fails with msg
Monomorphic equality checks
val is_none :
?loc:string ->
?msg:string ->
?pp:(Format.formatter -> 'a -> unit) ->
'a option ->
unit
Check that an option value is None
.
Module type signatures
Assertions for equality/disequality
Checks for extra binary relations
Predefined modules for base types
Functors
Provide equality-based assertions for type X.t
Provide all comparisons assertions for type X.t