package bam

  1. Overview
  2. Docs
A property-based testing library with internal shrinking

Install

Dune Dependency

Authors

Maintainers

Sources

bam-0.3.tbz
sha256=6fbb38cad09fb8062841cc67e8cdac279304b8cf1ed14746944cd45246d2a888
sha512=ad2b880c50921d77e3f190d8e48066407fdf4b9bb168a0e1094cc8ffb234740b53d494089346797d6c7e5bae28f4eb5d95e22b31f9329e3c5817bc506cd652d4

doc/bam/Bam/Std/index.html

Module Bam.StdSource

Main module defining basic generators.

Sourcemodule Shrinker : sig ... end

This module contains the various strinking strategies which can be used with the generators below.

Sourcetype 'a t = 'a Gen.t

The type of random generators.

Sourceval return : 'a -> 'a t

return v is a generator for a constant value v.

Sourceval bind : 'a t -> ('a -> 'b t) -> 'b t

bind gen f returns a new generator depending on another generator. This should be the main building block to construct new generator. To understand how shrinking works with this operator please read shrinking.

Sourceval root : 'a t -> ('a -> 'b t) -> 'b t

root gen f applies f on the original value generated by gen and forgets about the shrinking. Hence, f is always applied to a single value. More details in shrinking.

Sourceval crunch : int -> 'a t -> 'a t

crunch i gen returns a new generator with a more aggressive shrinking. It increases the number of values that will be used during the shrinking. More details in shrinking.

Sourceval of_seq : 'a Seq.t -> 'a option t

of_seq seq returns a generator that will produce successively the values of the sequence until the sequence is empty. Those values are intended to be used as the root argument of other generators.

Sourceval int : ?root:int -> ?shrinker:int Shrinker.t -> ?min:int -> ?max:int -> unit -> int t

int ?root ?shrinker ?(min=0) ?(max=Int.max_int) () is a generator for integers. Bounds are inclusive.

Default strategy is Shrinker.t.Int0.

Sourceval int32 : ?root:int32 -> ?shrinker:int32 Shrinker.t -> ?min:int32 -> ?max:int32 -> unit -> int32 t

int ?root ?shrinker ?(min=0) ?(max=Int.max_int) () is a generator for integers. Bounds are inclusive.

Default strategy is Shrinker.t.Int0.

Sourceval int64 : ?root:int64 -> ?shrinker:int64 Shrinker.t -> ?min:int64 -> ?max:int64 -> unit -> int64 t

int ?root ?shrinker ?(min=0) ?(max=Int.max_int) () is a generator for integers. Bounds are inclusive.

Default strategy is Shrinker.t.Int0.

Sourceval float : ?root:float -> ?shrinker:float Shrinker.t -> ?min:float -> ?max:float -> unit -> float t

float ?root ?shrinker ?(min=0.) ?(max=Float.max_float) () generates integers. Bounds are inclusive.

Default strategy is Shrinker.t.Float0..

Sourceval pair : ?shrinker:('a * 'b) Shrinker.t -> 'a t -> 'b t -> ('a * 'b) t

pair ?shrinker left right () generates a pair using the left and right generators.

Default strategy is Shrinker.t.Pair_left.

Sourceval bool : ?shrinker:bool Shrinker.t -> unit -> bool t

bool ?shrinker () generates a boolean.x

Default strategy is Shrinker.t.Boolfalse.

Sourceval char : ?root:char -> ?shrinker:Char.t Shrinker.t -> ?printable:bool -> unit -> char t

char ?root ?shrinker ?(printable=true) () generates a char.

Default strategy is Shrinker.t.Char'a.

Sourceval list : ?shrinker:'a list Shrinker.t -> size:int t -> 'a t -> 'a list t

list ?shrinker ~size gen () generates a list of values using gen.

Default strategy is Shrinker.t.Prefix.

Sourceval string : ?shrinker:Char.t list Shrinker.t -> ?char:Char.t t -> size:int t -> unit -> string t

string ?shrinker ?char ~size () is mostly an alias for list ?shrinker ~char:(char ()).

Sourceval bytes : ?shrinker:Char.t list Shrinker.t -> ?char:Char.t t -> size:int t -> unit -> bytes t

bytes ?shrinker ?char ~size () is mostly an alias for list ?shrinker ~char:(char ~printable:false ()) ().

Sourceval oneof : ?shrinker:int Shrinker.t -> (int * 'a t) list -> 'a t

oneof ?shrinker list pick one generator of the list according to the distribution defined by the first elements of the list.

Default strategy is the same as for int. This generator can be thought as a repeated list of generators. The shrinker will choose particular index from the list.

Sourceval oneofg : ?shrinker:int Shrinker.t -> 'a t list -> 'a t

oneofg ?shrinker list is an alias for oneof ?shrinker (List.map (fun gen -> (1, gen)) list)

Sourceval oneofl : ?shrinker:int Shrinker.t -> 'a list -> 'a t

oneofl ?shrinker list is an alias for oneofg ?shrinker (List.map Gen.return list

Sourcemodule Syntax : sig ... end
OCaml

Innovation. Community. Security.