mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
add new random test
This commit is contained in:
parent
1dad12868e
commit
1e9e17a8b5
1 changed files with 28 additions and 0 deletions
|
|
@ -11,6 +11,34 @@
|
||||||
(*$inject
|
(*$inject
|
||||||
module M = Make(CCInt)
|
module M = Make(CCInt)
|
||||||
|
|
||||||
|
type op =
|
||||||
|
| Add of int * int
|
||||||
|
| Remove of int
|
||||||
|
| Remove_min
|
||||||
|
|
||||||
|
let gen_op () = CCRandom.(run ?st:None @@ choose_exn
|
||||||
|
[ return Remove_min
|
||||||
|
; map (fun x->Remove x) small_int
|
||||||
|
; pure (fun x y->Add (x,y)) <*> small_int <*> small_int])
|
||||||
|
and pp_op =let open Printf in
|
||||||
|
function Add (x,y) -> sprintf "Add %d %d" x y
|
||||||
|
| Remove x -> sprintf "Remove %d" x | Remove_min -> "Remove_min"
|
||||||
|
|
||||||
|
let apply_ops l m = List.fold_left
|
||||||
|
(fun m -> function
|
||||||
|
| Add (i,b) -> M.add i b m
|
||||||
|
| Remove i -> M.remove i m
|
||||||
|
| Remove_min ->
|
||||||
|
try let _, _, m' = M.extract_min m in m' with Not_found -> m
|
||||||
|
) m l
|
||||||
|
|
||||||
|
let op = gen_op, pp_op
|
||||||
|
|
||||||
|
*)
|
||||||
|
|
||||||
|
(*$Q & ~small:List.length ~count:200
|
||||||
|
Q.(list op) (fun l -> \
|
||||||
|
let m = apply_ops l M.empty in M.balanced m)
|
||||||
*)
|
*)
|
||||||
|
|
||||||
type 'a sequence = ('a -> unit) -> unit
|
type 'a sequence = ('a -> unit) -> unit
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue