Skip to content

Commit d32d612

Browse files
committed
Add a pair sampler generator
1 parent e82bc93 commit d32d612

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/grader/test_lib.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ module type S = sig
119119
val sample_bool : bool sampler
120120
val sample_list : ?min_size: int -> ?max_size: int -> ?dups: bool -> ?sorted: bool -> 'a sampler -> 'a list sampler
121121
val sample_array : ?min_size: int -> ?max_size: int -> ?dups: bool -> ?sorted: bool -> 'a sampler -> 'a array sampler
122+
val sample_pair : 'a sampler -> 'b sampler -> ('a * 'b) sampler
122123
val sample_alternatively : 'a sampler list -> 'a sampler
123124
val sample_cases : 'a list -> 'a sampler
124125
val sample_option : 'a sampler -> 'a option sampler
@@ -1862,6 +1863,9 @@ module Make
18621863
let sample_list ?min_size ?max_size ?dups ?sorted sample () =
18631864
Array.to_list (sample_array ?min_size ?max_size ?dups ?sorted sample ())
18641865
1866+
let sample_pair sample1 sample2 () =
1867+
(sample1 (), sample2 ())
1868+
18651869
let printable_funs = ref []
18661870
18671871
let fun_printer ppf f =

src/grader/test_lib.mli

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,11 @@ module type S = sig
472472
-> 'a sampler
473473
-> 'a array sampler
474474

475+
(** [sample_pair s1 s2] returns a sampler that generates a value
476+
of type ['a * 'b] using [s1] and [s2] to generate values of
477+
type ['a] and ['b], respectively, on each call. *)
478+
val sample_pair : 'a sampler -> 'b sampler -> ('a * 'b) sampler
479+
475480
(** [sample_alternatively s] returns a sampler that mimics
476481
randomly the behavior of one of [s] sampler and change at each
477482
call. *)

0 commit comments

Comments
 (0)