Module Stateful.Rule

type 'state t

A rule is one possible action in a stateful test.

val create : name:string -> step:(test_case -> 'state -> 'state) -> 'state t

Declares a rule.

  • name is printed in the final output when the rule is run
  • step tc state performs one application of the rule, drawing any arguments it needs from tc and returning the new state.

To trace the state a rule produces on a failing replay, pass ?sexp_of_state to run.

let push =
  Stateful.Rule.create ~name:"push" ~step:(fun tc stack ->
      let n = draw tc (Generators.integers ~min_value:0 ~max_value:100 ()) in
      n :: stack)
val name : _ t -> string

Returns the name of the rule.

let label = Stateful.Rule.name push