Up — package qcheck-core
Generate Random Values type 'a t
= Random.State.t ‑> 'a
A random generator for values of type 'a.
type 'a sized
= int ‑> Random.State.t ‑> 'a
Random generator with a size bound.
Create a constant generator.
val (>>=) : 'a t ‑> ('a ‑> 'b t ) ‑> 'b t
Monadic bind for writing dependent generators. First generates an 'a
and then
passes it to the given function, to generate a 'b
.
val (<*>) : ('a ‑> 'b ) t ‑> 'a t ‑> 'b t
Infix operator for composing a function generator and an argument generator
into a result generator.
val map : ('a ‑> 'b ) ‑> 'a t ‑> 'b t
map f g
transforms a generator g
by applying f
to each generated element.
val map2 : ('a ‑> 'b ‑> 'c ) ‑> 'a t ‑> 'b t ‑> 'c t
map2 f g1 g2
transforms two generators g1
and g2
by applying f
to each
pair of generated elements.
val map3 : ('a ‑> 'b ‑> 'c ‑> 'd ) ‑> 'a t ‑> 'b t ‑> 'c t ‑> 'd t
map3 f g1 g2 g3
transforms three generators g1
, g2
, and g3
by applying f
to each triple of generated elements.
val (>|=) : 'a t ‑> ('a ‑> 'b ) ‑> 'b t
An infix synonym for map .
val oneof : 'a t list ‑> 'a t
Constructs a generator that selects among a given list of generators.
val oneofl : 'a list ‑> 'a t
Constructs a generator that selects among a given list of values.
val oneofa : 'a array ‑> 'a t
Constructs a generator that selects among a given array of values.
val frequency : (int * 'a t ) list ‑> 'a t
Constructs a generator that selects among a given list of generators.
Each of the given generators are chosen based on a positive integer weight.
val frequencyl : (int * 'a ) list ‑> 'a t
Constructs a generator that selects among a given list of values.
Each of the given values are chosen based on a positive integer weight.
val frequencya : (int * 'a ) array ‑> 'a t
Constructs a generator that selects among a given array of values.
Each of the array entries are chosen based on a positive integer weight.
val shuffle_a : 'a array ‑> unit t
Shuffles the array in place.
val shuffle_l : 'a list ‑> 'a list t
Creates a generator of shuffled lists.
Generates floating point numbers.
Generates positive floating point numbers (0. included).
Generates negative floating point numbers. (-0. included)
Generates small natural numbers.
Generates non-strictly negative integers (0 included).
Generates non-strictly positive integers uniformly (0 included).
Generates integers uniformly.
Small UNSIGNED integers, for retrocompatibility.
val small_signed_int : int t
val int_bound : int ‑> int t
Uniform integer generator producing integers within 0... bound
.
Raises Invalid_argument : if the argument is negative.val int_range : int ‑> int ‑> int t
Uniform integer generator producing integers within low,high
.
Raises Invalid_argument : if low > high
or if the range is larger than max_int
.val graft_corners : 'a t ‑> 'a list ‑> unit ‑> 'a t
graft_corners gen l ()
makes a new generator that enumerates
the corner cases in l
and then behaves like g
.
val int_pos_corners : int list
Non-negative corner cases for int.
val int_corners : int list
All corner cases for int.
val (--) : int ‑> int ‑> int t
Generates (unsigned) int32
values.
Generates (unsigned) int64
values.
val list : 'a t ‑> 'a list t
Builds a list generator from an element generator. List size is generated by nat .
val list_size : int t ‑> 'a t ‑> 'a list t
Builds a list generator from a (non-negative) size generator and an element generator.
val list_repeat : int ‑> 'a t ‑> 'a list t
list_repeat i g
builds a list generator from exactly i
elements generated by g
.
val array : 'a t ‑> 'a array t
Builds an array generator from an element generator. Array size is generated by nat .
val array_size : int t ‑> 'a t ‑> 'a array t
Builds an array generator from a (non-negative) size generator and an element generator.
val array_repeat : int ‑> 'a t ‑> 'a array t
array_repeat i g
builds an array generator from exactly i
elements generated by g
.
val opt : 'a t ‑> 'a option t
val pair : 'a t ‑> 'b t ‑> ('a * 'b ) t
val triple : 'a t ‑> 'b t ‑> 'c t ‑> ('a * 'b * 'c ) t
val quad : 'a t ‑> 'b t ‑> 'c t ‑> 'd t ‑> ('a * 'b * 'c * 'd ) t
Generates characters upto character code 255.
Generates printable characters.
Generates numeral characters.
val string_size : ?gen:char t ‑> int t ‑> string t
Builds a string generator from a (non-negative) size generator.
Accepts an optional character generator (the default is char ).
val string : ?gen:char t ‑> string t
Builds a string generator. String size is generated by nat .
Accepts an optional character generator (the default is char ).
val small_string : ?gen:char t ‑> string t
Builds a string generator. String size is in the range 0--10
.
Accepts an optional character generator (the default is char ).
val small_list : 'a t ‑> 'a list t
Generates lists of small size (range 0 -- 10
).
val join : 'a t t ‑> 'a t
Collapses a generator of generators to simply a generator.
Creates a generator from a size-bounded generator by first
generating a size using nat and passing the result to the size-bounded generator.
val sized_size : int t ‑> 'a sized ‑> 'a t
Creates a generator from a size-bounded generator by first
generating a size using the integer generator and passing the result
to the size-bounded generator.
Fixpoint combinator for generating recursive, size-bounded data types.
The passed size-parameter should decrease to ensure termination.
Example:
type tree = Leaf of int | Node of tree * tree
let leaf x = Leaf x
let node x y = Node (x,y)
let g = QCheck.Gen.(sized @@ fix
(fun self n -> match n with
| 0 -> map leaf nat
| n ->
frequency
[1, map leaf nat;
2, map2 node (self (n/2)) (self (n/2))]
))
val generate : ?rand:Random.State.t ‑> n:int ‑> 'a t ‑> 'a list
generate ~n g
generates n
instances of g
.
val generate1 : ?rand:Random.State.t ‑> 'a t ‑> 'a
generate1 g
generates one instance of g
.