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/oxcaml_api.html

Mode-annotated API

This page lists every public signature that has a mode in OxCaml. Only concurrent state machines need modes.

A concurrent rule body is portable. Each combinator has a portable version, which you select with [@mode portable]:

  let keys =
    (map [@mode portable]) Key.of_int (integers ~min_value:0 ~max_value:99 ())

The primitive generators (Hegel.integers, Hegel.text, ...) are already portable. [@@deriving hegel_generator ~portable] derives a portable generator:

  type point =
    { x : int
    ; y : int
    }
  [@@deriving hegel_generator ~portable]

[@mode portable] requires ppx_template in the pps of the dune stanza that builds the code. ppx_template is included in ppx_jane, ppx_hegel_test or ppx_hegel_generator. Without it, OxCaml ignores the attribute and uses the nonportable version.

Module-level defaults

These modules declare @@ portable as their default: Hegel, Hegel.Generators, Hegel.Derive, Hegel.Settings, Hegel_jane, Hegel_jane_concurrent, and the Hegel.Stateful submodules Hegel.Stateful.Concurrent_pool, Hegel.Stateful.Rule, Hegel.Stateful.Invariant, and Hegel.Stateful.Concurrent_rule. The Hegel.Stateful runners (Hegel.Stateful.run, Hegel.Stateful.run_concurrent) are not portable.

Types

Hegel.test_case

type test_case : value mod portable contended

Hegel.Generators.generator

type ('a, 'p) generator : value mod contended

Combinators

val%template map
  :  ('a -> 'b) @ m
  -> ('a, 'p) generator @ m
  -> ('b, unprintable) generator @ m
[@@mode m = (nonportable, portable)]

val%template just : ('a : value mod c). 'a @ m -> ('a, unprintable) generator @ m
[@@mode (m, c) = ((nonportable, uncontended), (portable, contended))]

val%template sampled_from
  : ('a : value mod c). 'a list @ m -> ('a, unprintable) generator @ m
[@@mode (m, c) = ((nonportable, uncontended), (portable, contended))]

with_printer, printer, composite, flat_map, filter, one_of, optional, tuples2/tuples3/tuples4, lists, assoc_lists, hash_tables, make_hash_tables, make_characters, make_dates, make_times, make_datetimes, functions/functions2/functions3, and Hegel_jane.hash_tables use the same template as map.

The primitives return @ portable and have one version: Hegel.booleans, Hegel.integers, Hegel.floats, Hegel.text, Hegel.characters, Hegel.chars, Hegel.binary, Hegel.emails, Hegel.urls, Hegel.domains, Hegel.from_regex, Hegel.dates, Hegel.times, Hegel.datetimes, Hegel.ip_addresses, and the Hegel_jane generators other than Hegel_jane.hash_tables.

Hegel.Stateful

Hegel.Stateful.Concurrent_pool.t

type ('a : value mod portable contended) t : value mod portable contended

Hegel.Stateful.Concurrent_pool.create

val create : ?clone:('a -> 'a) @ portable -> test_case -> 'a t

Hegel.Stateful.Concurrent_rule.t

type ('ctx, 'state) t : value mod portable contended

Hegel.Stateful.Concurrent_rule.create

val create
  :  ?group:string
  -> ?weight:float
  -> name:string
  -> step:(test_case -> 'ctx @ local -> 'state @ contended -> unit) @ portable
  -> unit
  -> ('ctx, 'state) t

Hegel.Stateful.run_concurrent

val run_concurrent
  :  concurrency:'ctx Concurrency.t @ local
  -> ?min_concurrency:int
  -> ?max_concurrency:int
  -> ?step_count:int
  -> ?sexp_of_state:('state -> Sexplib0.Sexp.t)
  -> test_case
  -> (module Concurrent_state_machine with type ctx = 'ctx and type state = 'state)
  -> init:'state @ portable
  -> unit

Hegel.Concurrency

Hegel.Concurrency.t

type 'ctx t =
  { spawn_join_n :
      n:int
      -> (f:('ctx @ local -> int -> outcome) @ portable -> outcome list @ contended) @ local
  }

Hegel_jane_concurrent

of_concurrent

val of_concurrent : 'a Concurrent.t @ local -> 'a ctx Hegel.Concurrency.t @ local