From 2f196ee9a2bc49ce8b5dcd48a881d0562df41777 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Mon, 18 Apr 2016 15:05:59 +0200 Subject: [PATCH] more doc and test for CCRandom --- src/core/CCRandom.ml | 7 +++++++ src/core/CCRandom.mli | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/core/CCRandom.ml b/src/core/CCRandom.ml index ed8ed0a4..ea269af2 100644 --- a/src/core/CCRandom.ml +++ b/src/core/CCRandom.ml @@ -118,6 +118,13 @@ let split_list i ~len st = else None +(*$Q + Q.(pair small_int small_int) (fun (i,j) -> \ + let len, n = min i j, max i j in \ + let l = QCheck.Gen.generate1 (split_list n ~len) in \ + match l with None -> true | Some l -> l<> [] && List.for_all (fun x->x>0) l) +*) + let retry ?(max=10) g st = let rec aux n = match g st with diff --git a/src/core/CCRandom.mli b/src/core/CCRandom.mli index ee6b4237..d5490e2f 100644 --- a/src/core/CCRandom.mli +++ b/src/core/CCRandom.mli @@ -102,7 +102,8 @@ val split : int -> (int * int) option t val split_list : int -> len:int -> int list option t (** Split a value [n] into a list of values whose sum is [n] - and whose length is [length]. + and whose length is [length]. The list is never empty and does not + contain [0]. @return [None] if the value is too small *) val retry : ?max:int -> 'a option t -> 'a option t