module Gen:sig..end
type'at =Stdlib.Random.State.t -> 'a
A random generator for values of type 'a.
type'asized =int -> Stdlib.Random.State.t -> 'a
Random generator with a size bound.
val return : 'a -> 'a tCreate a constant generator.
val pure : 'a -> 'a tSynonym for QCheck.Gen.return
val (>>=) : 'a t -> ('a -> 'b t) -> 'b tMonadic 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 tInfix operator for composing a function generator and an argument generator into a result generator.
val map : ('a -> 'b) -> 'a t -> 'b tmap f g transforms a generator g by applying f to each generated element.
val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c tmap2 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 tmap3 f g1 g2 g3 transforms three generators g1, g2, and g3 by applying f
to each triple of generated elements.
val map_keep_input : ('a -> 'b) -> 'a t -> ('a * 'b) tmap_keep_input f g transforms a generator g by applying f to each generated element.
Returns both the generated element from g and the output from f.
val (>|=) : 'a t -> ('a -> 'b) -> 'b tAn infix synonym for QCheck.Gen.map.
val (<$>) : ('a -> 'b) -> 'a t -> 'b tAn infix synonym for QCheck.Gen.map
val oneof : 'a t list -> 'a tConstructs a generator that selects among a given list of generators.
Invalid_argument or Failure if list is emptyval oneofl : 'a list -> 'a tConstructs a generator that selects among a given list of values.
Invalid_argument or Failure if list is emptyval oneofa : 'a array -> 'a tConstructs a generator that selects among a given array of values.
Invalid_argument or Failure if list is emptyval frequency : (int * 'a t) list -> 'a tConstructs 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 tConstructs 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 tConstructs 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 tShuffles the array in place.
val shuffle_l : 'a list -> 'a list tCreates a generator of shuffled lists.
val shuffle_w_l : (int * 'a) list -> 'a list tCreates a generator of weighted shuffled lists. A given list is shuffled on each generation according to the weights of its elements. An element with a larger weight is more likely to be at the front of the list than an element with a smaller weight. If we want to pick random elements from the (head of) list but need to prioritize some elements over others, this generator can be useful.
Example: given a weighted list [1, "one"; 5, "five"; 10, "ten"], the generator is
more likely to generate ["ten"; "five"; "one"] or ["five"; "ten"; "one"] than
["one"; "ten"; "five"] because "ten" and "five" have larger weights than "one".
val range_subset : size:int -> int -> int -> int array trange_subset ~size:k low high generates an array of length k
of sorted distinct integers in the range low..high (included).
Complexity O(k log k), drawing k random integers.
Invalid_argument outside the valid region 0 <= k <= high-low+1.val array_subset : int -> 'a array -> 'a array tarray_subset k arr generates a sub-array of k elements
at distinct positions in the input array arr,
in the same order.
Complexity O(k log k), drawing k random integers.
Invalid_argument outside the valid region
0 <= size <= Array.length arr.val unit : unit tThe unit generator.
val bool : bool tThe boolean generator.
val float : float tGenerates floating point numbers.
val pfloat : float tGenerates positive floating point numbers (0. included).
val nfloat : float tGenerates negative floating point numbers. (-0. included)
val float_bound_inclusive : float -> float tfloat_bound_inclusive bound returns a random floating-point number between 0 and
bound (inclusive). If bound is negative, the result is negative or zero. If
bound is 0, the result is 0.
val float_bound_exclusive : float -> float tfloat_bound_exclusive bound returns a random floating-point number between 0 and
bound (exclusive). If bound is negative, the result is negative or zero.
Invalid_argument if bound is zero.val float_range : float -> float -> float tfloat_range low high generates floating-point numbers within low and high (inclusive)
Invalid_argument if high < low or if the range is larger than max_float.val (--.) : float -> float -> float tSynonym for float_range
val nat : int tGenerates small natural numbers.
val big_nat : int tGenerates natural numbers, possibly large.
val neg_int : int tGenerates non-strictly negative integers (0 included).
val pint : int tGenerates non-strictly positive integers uniformly (0 included).
val int : int tGenerates integers uniformly.
val small_nat : int tSmall integers (< 100)
val small_int : int tQCheck.Gen.small_nat.Small UNSIGNED integers, for retrocompatibility.
val small_signed_int : int tSmall SIGNED integers, based on QCheck.Gen.small_nat.
val int_bound : int -> int tUniform integer generator producing integers between 0 and bound
(inclusive).
For bound < 2^{30} - 1 uses Random.State.int for integer generation.
Invalid_argument if the argument is negative.val int_range : int -> int -> int tUniform integer generator producing integers within low,high (inclusive).
Invalid_argument if low > high.val graft_corners : 'a t -> 'a list -> unit -> 'a tgraft_corners gen l () makes a new generator that enumerates
the corner cases in l and then behaves like g.
val int_pos_corners : int listNon-negative corner cases for int.
val int_corners : int listAll corner cases for int.
val (--) : int -> int -> int tSynonym for QCheck.Gen.int_range.
val ui32 : int32 tGenerates (unsigned) int32 values.
val ui64 : int64 tGenerates (unsigned) int64 values.
val list : 'a t -> 'a list tBuilds a list generator from an element generator. List size is generated by QCheck.Gen.nat.
val list_size : int t -> 'a t -> 'a list tBuilds a list generator from a (non-negative) size generator and an element generator.
val list_repeat : int -> 'a t -> 'a list tlist_repeat i g builds a list generator from exactly i elements generated by g.
val array : 'a t -> 'a array tBuilds an array generator from an element generator. Array size is generated by QCheck.Gen.nat.
val array_size : int t -> 'a t -> 'a array tBuilds an array generator from a (non-negative) size generator and an element generator.
val array_repeat : int -> 'a t -> 'a array tarray_repeat i g builds an array generator from exactly i elements generated by g.
val option : ?ratio:float -> 'a t -> 'a option tAn option generator, with optional ratio.
ratio : a float between 0. and 1. indicating the probability of a sample to be Some _
rather than None.val opt : ?ratio:float -> 'a t -> 'a option topt is an alias of QCheck.Gen.option for backward compatibility.
val pair : 'a t -> 'b t -> ('a * 'b) tGenerates pairs.
val triple : 'a t ->
'b t -> 'c t -> ('a * 'b * 'c) tGenerates triples.
val quad : 'a t ->
'b t ->
'c t -> 'd t -> ('a * 'b * 'c * 'd) tGenerates quadruples.
gen1, then gen2, then ... val tup2 : 'a t -> 'b t -> ('a * 'b) t
val tup3 : 'a t ->
'b t -> 'c t -> ('a * 'b * 'c) t
val tup4 : 'a t ->
'b t ->
'c t -> 'd t -> ('a * 'b * 'c * 'd) t
val tup5 : 'a t ->
'b t ->
'c t ->
'd t -> 'e t -> ('a * 'b * 'c * 'd * 'e) t
val tup6 : 'a t ->
'b t ->
'c t ->
'd t ->
'e t ->
'f t -> ('a * 'b * 'c * 'd * 'e * 'f) t
val tup7 : 'a t ->
'b t ->
'c t ->
'd t ->
'e t ->
'f t ->
'g t -> ('a * 'b * 'c * 'd * 'e * 'f * 'g) t
val tup8 : 'a t ->
'b t ->
'c t ->
'd t ->
'e t ->
'f t ->
'g t ->
'h t -> ('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h) t
val tup9 : 'a t ->
'b t ->
'c t ->
'd t ->
'e t ->
'f t ->
'g t ->
'h t ->
'i t -> ('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h * 'i) t
val char : char tGenerates characters upto character code 255.
val printable : char tGenerates printable ascii characters - either '\n' or in the range 32 to 126, inclusive
val numeral : char tGenerates numeral characters.
val char_range : char -> char -> char tGenerates chars between the two bounds, inclusive.
Example: char_range 'a' 'z' for all lower case ascii letters.
val bytes_size : ?gen:char t -> int t -> bytes tBuilds a bytes generator from a (non-negative) size generator.
Accepts an optional character generator (the default is QCheck.Gen.char).
val bytes : ?gen:char t -> bytes tBuilds a bytes generator. Bytes size is generated by QCheck.Gen.nat.
Accepts an optional character generator (the default is QCheck.Gen.char).
See also QCheck.Gen.bytes_of and bytes_readable for versions without
optional parameters.
val bytes_of : char t -> bytes tBuilds a bytes generator using the given character generator.
val bytes_printable : bytes tGenerator using the QCheck.Gen.printable character generator.
val bytes_small : bytes tBuilds a bytes generator using the QCheck.Gen.char character generator, length is QCheck.Gen.small_nat
val bytes_small_of : char t -> bytes tBuilds a bytes generator using the given character generator, length is QCheck.Gen.small_nat.
val string_size : ?gen:char t -> int t -> string tBuilds a string generator from a (non-negative) size generator.
Accepts an optional character generator (the default is QCheck.Gen.char).
val string : ?gen:char t -> string tBuilds a string generator. String size is generated by QCheck.Gen.nat.
Accepts an optional character generator (the default is QCheck.Gen.char).
See also QCheck.Gen.string_of and QCheck.Gen.string_readable for versions without
optional parameters.
val string_of : char t -> string tBuilds a string generator using the given character generator.
val string_readable : string t
val string_printable : string tBuilds a string generator using the QCheck.Gen.printable character generator.
val small_string : ?gen:char t -> string tBuilds a string generator, length is QCheck.Gen.small_nat
Accepts an optional character generator (the default is QCheck.Gen.char).
val string_small : string tBuilds a string generator using the QCheck.Gen.char character generator, length is QCheck.Gen.small_nat
val string_small_of : char t -> string tBuilds a string generator using the given character generator, length is QCheck.Gen.small_nat.
val small_list : 'a t -> 'a list tGenerates lists of small size (see QCheck.Gen.small_nat).
val flatten_l : 'a t list -> 'a list tGenerate a list of elements from individual generators
val flatten_a : 'a t array -> 'a array tGenerate an array of elements from individual generators
val flatten_opt : 'a t option -> 'a option tGenerate an option from an optional generator
val flatten_res : ('a t, 'e) Stdlib.result -> ('a, 'e) Stdlib.result tGenerate a result from Ok g, an error from Error e
val small_array : 'a t -> 'a array tGenerates arrays of small size (see QCheck.Gen.small_nat).
val join : 'a t t -> 'a tCollapses a generator of generators to simply a generator.
val sized : 'a sized -> 'a tCreates a generator from a size-bounded generator by first
generating a size using QCheck.Gen.nat and passing the result to the size-bounded generator.
val sized_size : int t -> 'a sized -> 'a tCreates 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.
val fix : (('a -> 'b t) -> 'a -> 'b t) -> 'a -> 'b tParametrized fixpoint combinator for generating recursive values.
The fixpoint is parametrized over an arbitrary state ('a), and the fixpoint computation may change the value of this state in the recursive calls.
In particular, this can be used for size-bounded generators ('a is int). 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 nat_split2 : int -> (int * int) tnat_split2 n generates pairs (n1, n2) of natural numbers
with n1 + n2 = n.
This is useful to split sizes to combine sized generators.
val pos_split2 : int -> (int * int) tpos_split2 n generates pairs (n1, n2) of strictly positive
(nonzero) natural numbers with n1 + n2 = n.
Invalid_argument unless n >= 2.
This is useful to split sizes to combine sized generators.val nat_split : size:int -> int -> int array tnat_split ~size:k n generates k-sized arrays n1,n2,..nk
of natural numbers in [0;n] with n1 + n2 + ... + nk = n.
This is useful to split sizes to combine sized generators.
Complexity O(k log k).
val pos_split : size:int -> int -> int array tpos_split ~size:k n generates k-sized arrays n1,n2,..nk
of strictly positive (non-zero) natural numbers with
n1 + n2 + ... + nk = n.
This is useful to split sizes to combine sized generators.
Complexity O(k log k).
Invalid_argument unless 0 < k <= n or 0 = k = n.val delay : (unit -> 'a t) -> 'a tDelay execution of some code until the generator is actually called. This can be used to manually implement recursion or control flow in a generator.
val generate : ?rand:Stdlib.Random.State.t -> n:int -> 'a t -> 'a listgenerate ~n g generates n instances of g.
val generate1 : ?rand:Stdlib.Random.State.t -> 'a t -> 'agenerate1 g generates one instance of g.
val let+ : 'a t -> ('a -> 'b) -> 'b t
val and+ : 'a t -> 'b t -> ('a * 'b) t
val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t
val ( and* ) : 'a t -> 'b t -> ('a * 'b) t