@@ -34,7 +34,7 @@ content will appear. *)
34
34
35
35
{1 Examples}
36
36
37
- - "{! List.rev} is involutive" (the test passes so [check_exn] returns [()]):
37
+ - "[ List.rev] is involutive" (the test passes so [check_exn] returns [()]):
38
38
39
39
{[
40
40
let test =
@@ -233,8 +233,18 @@ module Gen : sig
233
233
234
234
val small_int_corners : unit -> int t
235
235
(* * As {!small_int}, but each newly created generator starts with
236
- a list of corner cases before falling back on random generation. *)
236
+ a list of corner cases before falling back on random generation.
237
237
238
+ Note that [small_int_corners ()] is stateful, meaning that once the list of
239
+ corner cases has been emitted, subsequent calls will not reproduce them.
240
+ As a consequence, in the following example, the first test fails with a
241
+ counter example, whereas the second rerun does not:
242
+ {[
243
+ let gen = QCheck2.Gen.small_int_corners ()
244
+ let t = QCheck2.Test.make ~name:"never max_int" gen (fun i -> i <> max_int)
245
+ let _ = QCheck_base_runner.run_tests ~verbose:true [t;t]
246
+ ]}
247
+ *)
238
248
239
249
val int32 : int32 t
240
250
(* * Generates uniform {!int32} values.
@@ -417,7 +427,7 @@ module Gen : sig
417
427
418
428
val make_primitive : gen : (Random .State .t -> 'a ) -> shrink : ('a -> 'a Seq .t ) -> 'a t
419
429
(* * [make_primitive ~gen ~shrink] creates a generator from a function [gen] that creates
420
- a random value (this function must only use the given {! Random.State.t} for randomness)
430
+ a random value (this function must only use the given [ Random.State.t] for randomness)
421
431
and a function [shrink] that, given a value [a], returns a lazy list of
422
432
"smaller" values (used when a test fails).
423
433
@@ -624,6 +634,11 @@ module Gen : sig
624
634
Does not shrink if the test fails on a grafted value.
625
635
Shrinks towards [gen] otherwise.
626
636
637
+ Note that [graft_corners gen l ()] is stateful, meaning that once the
638
+ elements of [l] have been emitted, subsequent calls will not reproduce
639
+ them. It is therefore recommended that separate tests each use a fresh
640
+ generator.
641
+
627
642
@since 0.6 *)
628
643
629
644
val int_pos_corners : int list
@@ -691,7 +706,7 @@ module Gen : sig
691
706
val option : ?ratio : float -> 'a t -> 'a option t
692
707
(* * [option gen] is an [option] generator that uses [gen] when generating [Some] values.
693
708
694
- Shrinks towards {! None} then towards shrinks of [gen].
709
+ Shrinks towards [ None] then towards shrinks of [gen].
695
710
696
711
@param ratio a float between [0.] and [1.] indicating the probability of a sample to be [Some _]
697
712
rather than [None] (value is [0.85]).
@@ -782,7 +797,7 @@ module Gen : sig
782
797
val flatten_opt : 'a t option -> 'a option t
783
798
(* * Generate an option from an optional generator.
784
799
785
- Shrinks towards {! None} then shrinks on the value.
800
+ Shrinks towards [ None] then shrinks on the value.
786
801
787
802
@since 0.13 *)
788
803
@@ -1272,16 +1287,16 @@ module Shrink : sig
1272
1287
*)
1273
1288
1274
1289
val int_towards : int -> int -> int Seq .t
1275
- (* * {!number_towards} specialized to {! int} . *)
1290
+ (* * {!number_towards} specialized to [ int] . *)
1276
1291
1277
1292
val int32_towards : int32 -> int32 -> int32 Seq .t
1278
- (* * {!number_towards} specialized to {! int32} . *)
1293
+ (* * {!number_towards} specialized to [ int32] . *)
1279
1294
1280
1295
val int64_towards : int64 -> int64 -> int64 Seq .t
1281
- (* * {!number_towards} specialized to {! int64} . *)
1296
+ (* * {!number_towards} specialized to [ int64] . *)
1282
1297
1283
1298
val float_towards : float -> float -> float Seq .t
1284
- (* * {!number_towards} specialized to {! float} .
1299
+ (* * {!number_towards} specialized to [ float] .
1285
1300
1286
1301
There are various ways to shrink a float:
1287
1302
- try removing floating digits, i.e. towards integer values
@@ -2027,8 +2042,8 @@ val find_example_gen :
2027
2042
Below are the most common situations you may encounter:
2028
2043
- as shrinking is now integrated, several function arguments like [~shrink] or [~rev] have been removed: you
2029
2044
can remove such reverse functions, they will no longer be necessary.
2030
- - accessor functions like {!QCheck.gen} have been renamed to consistent names like {!get_gen}.
2031
- - {!QCheck.map_keep_input} has been removed: you can use {!map} directly.
2045
+ - accessor functions like {!val: QCheck.gen} have been renamed to consistent names like {!Test. get_gen}.
2046
+ - {!QCheck.map_keep_input} has been removed: you can use {!Gen. map} directly.
2032
2047
- {!Gen.t} is no longer public, it is now abstract: it is recommended to use
2033
2048
{{!section:Gen.composing_generators} generator composition} to make generators. {!Gen.make_primitive}
2034
2049
was added to create generators with finer control (in particular of shrinking).
0 commit comments