The two Gen.generate* functions are very handy at top-level, e.g., to trigger generation without going through the test-and-check-property loop:
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]. *)
However, because they use a default, self-initializing Random.State they should not be combined with the other Gen combinators to form a larger generator - as the self-initialization breaks reproducability completely (I've seen this happen more than once):
let generate ?(rand=Random.State.make_self_init()) ~n g =
list_repeat n g rand
let generate1 ?(rand=Random.State.make_self_init()) g = g rand
I suggest we add a big red warning flag to their documentation.
The two
Gen.generate*
functions are very handy at top-level, e.g., to trigger generation without going through the test-and-check-property loop:However, because they use a default, self-initializing
Random.State
they should not be combined with the otherGen
combinators to form a larger generator - as the self-initialization breaks reproducability completely (I've seen this happen more than once):I suggest we add a big red warning flag to their documentation.