Stateful.InvariantA property that must always be true in a stateful test.
val create :
name:string ->
inv:(test_case -> 'state -> unit) ->
?always_check:bool ->
unit ->
'state tDeclares an invariant.
name is printed in the final output if the test fails on an invariantinv tc state checks the invariant on state. Anything it draws or notes through tc prints indented under the line before it.always_check defaults to false. When true, the invariant is checked after every step. Otherwise, it is sampled.Every invariant is checked on the initial and final states.
With the PPX, an invariant takes the following option: [@@invariant { always_checked = true | false }].
let short =
Stateful.Invariant.create
~name:"short"
~inv:(fun _tc stack -> assert (List.length !stack < 10))
()
;;val name : _ t -> stringReturns the name of the invariant.