package hegel

  1. Overview
  2. Docs
Hegel property-based testing library for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

hegel-0.24.1-opam.tar.gz
md5=d6985126c61aec88003bc03555a0d763
sha512=03e73b752dfb9ea711bc95fd87a777c068a789e7094650c5297fd37ad023292528a6fc69ea88986c02ea3f24c5c24d28353c220fd87595ce047521eecf94e0a8

doc/hegel/Hegel/Stateful/Rule/index.html

Module Stateful.RuleSource

One possible action in a sequential stateful test.

Sourcetype 'state t
Sourceval create : name:string -> ?weight:float -> step:(test_case -> 'state -> unit) -> unit -> 'state t

Declares a rule.

  • name is printed in the final output when the rule is run.
  • weight is a hint of how frequently the rule should be run. The default weight is 1.0, and weights must be finite and strictly positive.
  • step tc state performs one application of the rule, drawing any arguments it needs from tc and updating state in place. tc is valid only for that step.

With the PPX, a rule takes the following option: [@@rule { weight = ... }].

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

Returns the name of the rule.

let label = Stateful.Rule.name push
Sourceval weight : _ t -> float

Returns the weight of the rule