mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2026-03-12 00:08:33 -04:00
fix (#485)
This commit is contained in:
parent
bcfa092a73
commit
91cc585d5f
38 changed files with 284 additions and 289 deletions
|
|
@ -12,7 +12,7 @@ depends: [
|
|||
"dune" {>= "3.0"}
|
||||
"ocaml" {>= "4.08"}
|
||||
"containers" {= version}
|
||||
"qcheck-core" {>= "0.18" & with-test}
|
||||
"qcheck-core" {>= "0.91" & with-test}
|
||||
"iter" {with-test}
|
||||
"gen" {with-test}
|
||||
"mdx" {with-test}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ depends: [
|
|||
"ocaml" {>= "4.08"}
|
||||
"either"
|
||||
"dune-configurator"
|
||||
"qcheck-core" {>= "0.18" & with-test}
|
||||
"qcheck-core" {>= "0.91" & with-test}
|
||||
"yojson" {with-test}
|
||||
"iter" {with-test}
|
||||
"gen" {with-test}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
dune-configurator
|
||||
(qcheck-core
|
||||
(and
|
||||
(>= 0.18)
|
||||
(>= 0.91)
|
||||
:with-test))
|
||||
(yojson :with-test)
|
||||
(iter :with-test)
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
(= :version))
|
||||
(qcheck-core
|
||||
(and
|
||||
(>= 0.18)
|
||||
(>= 0.91)
|
||||
:with-test))
|
||||
(iter :with-test)
|
||||
(gen :with-test)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ true
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(list_of_size Gen.(0 -- 40) printable_string)
|
||||
Q.(list_size Gen.(0 -- 40) string_printable)
|
||||
(fun l ->
|
||||
let l' = ref [] in
|
||||
File.with_temp ~prefix:"test_containers" ~suffix:"" (fun name ->
|
||||
|
|
@ -27,7 +27,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(list_of_size Gen.(0 -- 40) printable_string)
|
||||
Q.(list_size Gen.(0 -- 40) string_printable)
|
||||
(fun l ->
|
||||
let l' = ref [] in
|
||||
File.with_temp ~prefix:"test_containers" ~suffix:"" (fun name ->
|
||||
|
|
@ -39,7 +39,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(list_of_size Gen.(0 -- 40) printable_string)
|
||||
Q.(list_size Gen.(0 -- 40) string_printable)
|
||||
(fun l ->
|
||||
let s = ref "" in
|
||||
File.with_temp ~prefix:"test_containers1" ~suffix:"" (fun name1 ->
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ eq ~cmp:( = )
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(array_of_size Gen.(0 -- 30) printable_string)
|
||||
Q.(array_size Gen.(0 -- 30) string_printable)
|
||||
(fun a ->
|
||||
let b = sort_indices String.compare a in
|
||||
sorted String.compare a = Array.map (Array.get a) b)
|
||||
|
|
@ -127,18 +127,18 @@ eq ~cmp:( = )
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(array_of_size Gen.(0 -- 50) printable_string)
|
||||
Q.(array_size Gen.(0 -- 50) string_printable)
|
||||
(fun a ->
|
||||
let b = sort_ranking String.compare a in
|
||||
let a_sorted = sorted String.compare a in
|
||||
a = Array.map (Array.get a_sorted) b)
|
||||
;;
|
||||
|
||||
q Q.(array small_int) (fun a -> rev (rev a) = a);;
|
||||
q Q.(array nat_small) (fun a -> rev (rev a) = a);;
|
||||
t @@ fun () -> rev [| 1; 2; 3 |] = [| 3; 2; 1 |];;
|
||||
t @@ fun () -> rev [| 1; 2 |] = [| 2; 1 |];;
|
||||
t @@ fun () -> rev [||] = [||];;
|
||||
q Q.(array small_int) (fun a -> mem 1 a = Array.mem 1 a);;
|
||||
q Q.(array nat_small) (fun a -> mem 1 a = Array.mem 1 a);;
|
||||
eq (Some 3) (max Stdlib.compare [| 1; 2; 3 |]);;
|
||||
eq (Some 4) (max Stdlib.compare [| 4; -1; 2; 3 |]);;
|
||||
eq None (max Stdlib.compare [||]);;
|
||||
|
|
@ -217,17 +217,17 @@ t @@ fun () -> 4 -- 1 |> Array.to_list = [ 4; 3; 2; 1 ];;
|
|||
t @@ fun () -> 0 -- 0 |> Array.to_list = [ 0 ];;
|
||||
|
||||
q
|
||||
Q.(pair small_int small_int)
|
||||
Q.(pair nat_small nat_small)
|
||||
(fun (a, b) -> a -- b |> Array.to_list = CCList.(a -- b))
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair small_int small_int)
|
||||
Q.(pair nat_small nat_small)
|
||||
(fun (a, b) -> a --^ b |> Array.to_list = CCList.(a --^ b))
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair (array small_int) (array small_int))
|
||||
Q.(pair (array nat_small) (array nat_small))
|
||||
(fun (a, b) -> equal ( = ) a b = equal ( = ) b a)
|
||||
;;
|
||||
|
||||
|
|
@ -250,7 +250,7 @@ a = [| 3; 2; 1 |]
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(array_of_size Gen.(0 -- 100) small_int)
|
||||
Q.(array_size Gen.(0 -- 100) nat_small)
|
||||
(fun a ->
|
||||
let b = Array.copy a in
|
||||
for i = 0 to Array.length a - 1 do
|
||||
|
|
@ -294,7 +294,7 @@ module IA = struct
|
|||
type t = int array
|
||||
end
|
||||
|
||||
let gen_arr = Q.Gen.(array_size (1 -- 100) small_int)
|
||||
let gen_arr = Q.Gen.(array_size (1 -- 100) nat_small)
|
||||
|
||||
let arr_arbitrary =
|
||||
Q.make
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ let g_rand_b =
|
|||
match n with
|
||||
| 0 -> oneof base
|
||||
| n ->
|
||||
frequency
|
||||
oneof_weighted
|
||||
@@ List.map (fun x -> 2, x) base
|
||||
@ [
|
||||
1, list_size (0 -- 10) (self (n - 1)) >|= B.list;
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ let gen_op size : (_ * _) Gen.t =
|
|||
else
|
||||
[]
|
||||
in
|
||||
frequency
|
||||
oneof_weighted
|
||||
(base
|
||||
@ [
|
||||
1, return (Get_contents, size);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ let sexp_gen =
|
|||
match n with
|
||||
| 0 -> atom st
|
||||
| _ ->
|
||||
frequency
|
||||
oneof_weighted
|
||||
[
|
||||
1, atom; 2, map mklist (list_size (0 -- 10) (self (n / 10)));
|
||||
]
|
||||
|
|
|
|||
|
|
@ -26,16 +26,16 @@ let gen_c : Cbor.t Q.Gen.t =
|
|||
let+ f = float in
|
||||
`Float f );
|
||||
( 2,
|
||||
let* n = frequency [ 20, 0 -- 150; 1, 151 -- 100_000 ] in
|
||||
let* n = oneof_weighted [ 20, 0 -- 150; 1, 151 -- 100_000 ] in
|
||||
let+ s = string_size ~gen:printable (return n) in
|
||||
`Text s );
|
||||
( 2,
|
||||
let* n = frequency [ 20, 0 -- 150; 1, 151 -- 100_000 ] in
|
||||
let* n = oneof_weighted [ 20, 0 -- 150; 1, 151 -- 100_000 ] in
|
||||
let+ s = string_size ~gen:char (return n) in
|
||||
`Bytes s );
|
||||
]
|
||||
in
|
||||
let g_base = frequency base in
|
||||
let g_base = oneof_weighted base in
|
||||
let rec_ =
|
||||
[
|
||||
( 2,
|
||||
|
|
@ -59,7 +59,7 @@ let gen_c : Cbor.t Q.Gen.t =
|
|||
`Tag (i, sub) );
|
||||
]
|
||||
in
|
||||
frequency
|
||||
oneof_weighted
|
||||
(if size > 0 then
|
||||
base @ rec_
|
||||
else
|
||||
|
|
|
|||
|
|
@ -4,12 +4,7 @@ include T;;
|
|||
|
||||
eq (Some 'a') (of_int (to_int 'a'));;
|
||||
eq None (of_int 257);;
|
||||
|
||||
q
|
||||
(Q.string_of_size (Q.Gen.return 1))
|
||||
(fun s -> Stdlib.( = ) (to_string s.[0]) s)
|
||||
;;
|
||||
|
||||
q (Q.string_size (Q.Gen.return 1)) (fun s -> Stdlib.( = ) (to_string s.[0]) s);;
|
||||
q (Q.int_range 65 90 |> Q.map Char.chr) CCChar.is_uppercase_ascii;;
|
||||
|
||||
q
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@ include T;;
|
|||
|
||||
q
|
||||
Q.(
|
||||
let p = small_list (pair small_int bool) in
|
||||
let p = list_small (pair nat_small bool) in
|
||||
pair p p)
|
||||
(fun (l1, l2) -> (list (pair int bool)) l1 l2 = (l1 = l2))
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ module T = (val Containers_testlib.make ~__FILE__ ())
|
|||
include T
|
||||
|
||||
(* A QCheck generator for natural numbers that are not too large (larger than
|
||||
* [small_nat] but smaller than [big_nat]), with a bias towards smaller numbers.
|
||||
* [nat_small] but smaller than [big_nat]), with a bias towards smaller numbers.
|
||||
* This also happens to be what QCheck uses for picking a length for a list
|
||||
* generated by [QCheck.list].
|
||||
* QCheck defines this generator under the name [nat] but does not expose it. *)
|
||||
|
|
@ -81,7 +81,7 @@ q ~name:"of_list, to_list_sorted" ~count:30
|
|||
[of_list], [to_list], [to_list_sorted]. *)
|
||||
|
||||
q ~name:"size" ~count:30
|
||||
Q.(list_of_size Gen.small_nat medium_nat)
|
||||
Q.(list_size Gen.nat_small medium_nat)
|
||||
(fun l -> l |> H.of_list |> H.size = (l |> List.length))
|
||||
;;
|
||||
|
||||
|
|
@ -154,61 +154,61 @@ true
|
|||
;;
|
||||
|
||||
q ~name:"fold"
|
||||
Q.(list_of_size Gen.small_nat medium_nat)
|
||||
Q.(list_size Gen.nat_small medium_nat)
|
||||
(fun l -> l |> H.of_list |> H.fold ( + ) 0 = (l |> List.fold_left ( + ) 0))
|
||||
;;
|
||||
|
||||
q ~name:"of_iter"
|
||||
Q.(list_of_size Gen.small_nat medium_nat)
|
||||
Q.(list_size Gen.nat_small medium_nat)
|
||||
(fun l ->
|
||||
l |> CCList.to_iter |> H.of_iter |> H.to_list_sorted
|
||||
= (l |> List.sort CCInt.compare))
|
||||
;;
|
||||
|
||||
q ~name:"of_seq"
|
||||
Q.(list_of_size Gen.small_nat medium_nat)
|
||||
Q.(list_size Gen.nat_small medium_nat)
|
||||
(fun l ->
|
||||
l |> CCList.to_seq |> H.of_seq |> H.to_list_sorted
|
||||
= (l |> List.sort CCInt.compare))
|
||||
;;
|
||||
|
||||
q ~name:"of_gen"
|
||||
Q.(list_of_size Gen.small_nat medium_nat)
|
||||
Q.(list_size Gen.nat_small medium_nat)
|
||||
(fun l ->
|
||||
l |> CCList.to_gen |> H.of_gen |> H.to_list_sorted
|
||||
= (l |> List.sort CCInt.compare))
|
||||
;;
|
||||
|
||||
q ~name:"to_iter"
|
||||
Q.(list_of_size Gen.small_nat medium_nat)
|
||||
Q.(list_size Gen.nat_small medium_nat)
|
||||
(fun l ->
|
||||
l |> H.of_list |> H.to_iter |> CCList.of_iter |> List.sort CCInt.compare
|
||||
= (l |> List.sort CCInt.compare))
|
||||
;;
|
||||
|
||||
q ~name:"to_seq"
|
||||
Q.(list_of_size Gen.small_nat medium_nat)
|
||||
Q.(list_size Gen.nat_small medium_nat)
|
||||
(fun l ->
|
||||
l |> H.of_list |> H.to_seq |> CCList.of_seq |> List.sort CCInt.compare
|
||||
= (l |> List.sort CCInt.compare))
|
||||
;;
|
||||
|
||||
q ~name:"to_gen"
|
||||
Q.(list_of_size Gen.small_nat medium_nat)
|
||||
Q.(list_size Gen.nat_small medium_nat)
|
||||
(fun l ->
|
||||
l |> H.of_list |> H.to_gen |> CCList.of_gen |> List.sort CCInt.compare
|
||||
= (l |> List.sort CCInt.compare))
|
||||
;;
|
||||
|
||||
q ~name:"to_iter_sorted"
|
||||
Q.(list_of_size Gen.small_nat medium_nat)
|
||||
Q.(list_size Gen.nat_small medium_nat)
|
||||
(fun l ->
|
||||
l |> H.of_list |> H.to_iter_sorted |> Iter.to_list
|
||||
= (l |> List.sort CCInt.compare))
|
||||
;;
|
||||
|
||||
q ~name:"to_seq_sorted"
|
||||
Q.(list_of_size Gen.small_nat medium_nat)
|
||||
Q.(list_size Gen.nat_small medium_nat)
|
||||
(fun l ->
|
||||
l |> H.of_list |> H.to_seq_sorted |> CCList.of_seq
|
||||
|> List.sort CCInt.compare
|
||||
|
|
@ -216,7 +216,7 @@ q ~name:"to_seq_sorted"
|
|||
;;
|
||||
|
||||
q ~name:"to_string with default sep"
|
||||
Q.(list_of_size Gen.small_nat medium_nat)
|
||||
Q.(list_size Gen.nat_small medium_nat)
|
||||
(fun l ->
|
||||
l |> H.of_list |> H.to_string string_of_int
|
||||
= (l |> List.sort CCInt.compare |> List.map string_of_int
|
||||
|
|
@ -224,7 +224,7 @@ q ~name:"to_string with default sep"
|
|||
;;
|
||||
|
||||
q ~name:"to_string with space as sep"
|
||||
Q.(list_of_size Gen.small_nat medium_nat)
|
||||
Q.(list_size Gen.nat_small medium_nat)
|
||||
(fun l ->
|
||||
l |> H.of_list
|
||||
|> H.to_string ~sep:" " string_of_int
|
||||
|
|
@ -233,7 +233,7 @@ q ~name:"to_string with space as sep"
|
|||
;;
|
||||
|
||||
q ~name:"Make_from_compare"
|
||||
Q.(list_of_size Gen.small_nat medium_nat)
|
||||
Q.(list_size Gen.nat_small medium_nat)
|
||||
(fun l ->
|
||||
let module H' = Make_from_compare (CCInt) in
|
||||
l |> H'.of_list |> H'.to_list_sorted = (l |> List.sort CCInt.compare))
|
||||
|
|
|
|||
|
|
@ -45,11 +45,11 @@ try
|
|||
with Division_by_zero -> true
|
||||
;;
|
||||
|
||||
q (Q.pair Q.small_signed_int Q.pos_int) (fun (n, m) ->
|
||||
q (Q.pair Q.int_small Q.int_pos) (fun (n, m) ->
|
||||
floor_div n m = int_of_float @@ floor (float n /. float m))
|
||||
;;
|
||||
|
||||
q (Q.pair Q.small_signed_int Q.pos_int) (fun (n, m) ->
|
||||
q (Q.pair Q.int_small Q.int_pos) (fun (n, m) ->
|
||||
floor_div n (-m) = int_of_float @@ floor (float n /. float (-m)))
|
||||
;;
|
||||
|
||||
|
|
@ -83,19 +83,19 @@ try
|
|||
with Division_by_zero -> true
|
||||
;;
|
||||
|
||||
q (Q.pair Q.int Q.pos_int) (fun (n, m) ->
|
||||
q (Q.pair Q.int Q.int_pos) (fun (n, m) ->
|
||||
let y = rem n m in
|
||||
y >= 0 && y < m)
|
||||
;;
|
||||
|
||||
q (Q.pair Q.int Q.pos_int) (fun (n, m) ->
|
||||
q (Q.pair Q.int Q.int_pos) (fun (n, m) ->
|
||||
let y = rem n (-m) in
|
||||
y > -m && y <= 0)
|
||||
;;
|
||||
|
||||
q (Q.pair Q.int Q.pos_int) (fun (n, m) -> n = (m * floor_div n m) + rem n m);;
|
||||
q (Q.pair Q.int Q.int_pos) (fun (n, m) -> n = (m * floor_div n m) + rem n m);;
|
||||
|
||||
q (Q.pair Q.int Q.pos_int) (fun (n, m) ->
|
||||
q (Q.pair Q.int Q.int_pos) (fun (n, m) ->
|
||||
n = (-m * floor_div n (-m)) + rem n (-m))
|
||||
;;
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ eq ~printer:Q.Print.(list int) [ 0 ] (range_by ~step:max_int 0 2 |> Iter.to_list
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair small_int small_int)
|
||||
Q.(pair nat_small nat_small)
|
||||
(fun (i, j) ->
|
||||
let i = min i j and j = max i j in
|
||||
CCList.equal CCInt.equal
|
||||
|
|
|
|||
|
|
@ -39,14 +39,14 @@ with Division_by_zero -> true
|
|||
;;
|
||||
|
||||
q
|
||||
(Q.pair (Q.map of_int Q.small_signed_int) (Q.map of_int Q.small_nat))
|
||||
(Q.pair (Q.map of_int Q.int_small) (Q.map of_int Q.nat_small))
|
||||
(fun (n, m) ->
|
||||
let m = m + 1l in
|
||||
floor_div n m = of_float @@ floor (to_float n /. to_float m))
|
||||
;;
|
||||
|
||||
q
|
||||
(Q.pair (Q.map of_int Q.small_signed_int) (Q.map of_int Q.small_nat))
|
||||
(Q.pair (Q.map of_int Q.int_small) (Q.map of_int Q.nat_small))
|
||||
(fun (n, m) ->
|
||||
let m = m + 1l in
|
||||
floor_div n (-m) = of_float @@ floor (to_float n /. to_float (-m)))
|
||||
|
|
@ -73,7 +73,7 @@ eq' [ 5l; 3l; 1l ] (range_by ~step:(neg 2l) 5l 0l |> Iter.to_list);;
|
|||
eq' [ 0l ] (range_by ~step:max_int 0l 2l |> Iter.to_list);;
|
||||
|
||||
q
|
||||
Q.(pair (map of_int small_int) (map of_int small_int))
|
||||
Q.(pair (map of_int nat_small) (map of_int nat_small))
|
||||
(fun (i, j) ->
|
||||
let i = min i j and j = max i j in
|
||||
CCList.equal CCInt32.equal
|
||||
|
|
|
|||
|
|
@ -39,14 +39,14 @@ with Division_by_zero -> true
|
|||
;;
|
||||
|
||||
q
|
||||
(Q.pair (Q.map of_int Q.small_signed_int) (Q.map of_int Q.small_nat))
|
||||
(Q.pair (Q.map of_int Q.int_small) (Q.map of_int Q.nat_small))
|
||||
(fun (n, m) ->
|
||||
let m = m + 1L in
|
||||
floor_div n m = of_float @@ floor (to_float n /. to_float m))
|
||||
;;
|
||||
|
||||
q
|
||||
(Q.pair (Q.map of_int Q.small_signed_int) (Q.map of_int Q.small_nat))
|
||||
(Q.pair (Q.map of_int Q.int_small) (Q.map of_int Q.nat_small))
|
||||
(fun (n, m) ->
|
||||
let m = m + 1L in
|
||||
floor_div n (-m) = of_float @@ floor (to_float n /. to_float (-m)))
|
||||
|
|
@ -81,7 +81,7 @@ eq' [ 5L; 3L; 1L ] (range_by ~step:(neg 2L) 5L 0L |> Iter.to_list);;
|
|||
eq' [ 0L ] (range_by ~step:max_int 0L 2L |> Iter.to_list);;
|
||||
|
||||
q
|
||||
Q.(pair (map of_int small_int) (map of_int small_int))
|
||||
Q.(pair (map of_int nat_small) (map of_int nat_small))
|
||||
(fun (i, j) ->
|
||||
let i = min i j and j = max i j in
|
||||
CCList.equal CCInt64.equal
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ include T
|
|||
|
||||
let lsort l = CCList.sort Stdlib.compare l;;
|
||||
|
||||
q Q.(pair small_nat (list int)) (fun (i, l) -> nth_opt l i = get_at_idx i l);;
|
||||
q Q.(pair nat_small (list int)) (fun (i, l) -> nth_opt l i = get_at_idx i l);;
|
||||
|
||||
q
|
||||
Q.(pair (list int) (list int))
|
||||
|
|
@ -15,19 +15,19 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair (list int) small_int)
|
||||
Q.(pair (list int) nat_small)
|
||||
(fun (l, n) ->
|
||||
CCOrd.equiv (CCList.compare_length_with l n) (CCInt.compare (length l) n))
|
||||
;;
|
||||
|
||||
q (Q.list Q.small_int) (fun l ->
|
||||
q (Q.list Q.nat_small) (fun l ->
|
||||
let f x = x + 1 in
|
||||
List.rev (List.rev_map f l) = map f l)
|
||||
;;
|
||||
|
||||
t @@ fun () -> [ 1; 2; 3 ] @ [ 4; 5; 6 ] = [ 1; 2; 3; 4; 5; 6 ];;
|
||||
t @@ fun () -> (1 -- 10_000) @ (10_001 -- 20_000) = 1 -- 20_000;;
|
||||
q Q.(small_list int) (fun l -> List.rev l = List.fold_left cons' [] l);;
|
||||
q Q.(list_small int) (fun l -> List.rev l = List.fold_left cons' [] l);;
|
||||
t @@ fun () -> cons_maybe (Some 1) [ 2; 3 ] = [ 1; 2; 3 ];;
|
||||
t @@ fun () -> cons_maybe None [ 2; 3 ] = [ 2; 3 ];;
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ t @@ fun () ->
|
|||
fold_right ( + ) (1 -- 1_000_000) 0 = List.fold_left ( + ) 0 (1 -- 1_000_000)
|
||||
;;
|
||||
|
||||
q (Q.list Q.small_int) (fun l -> l = fold_right (fun x y -> x :: y) l []);;
|
||||
q (Q.list Q.nat_small) (fun l -> l = fold_right (fun x y -> x :: y) l []);;
|
||||
|
||||
t @@ fun () ->
|
||||
fold_while
|
||||
|
|
@ -304,7 +304,7 @@ combine (1 -- 300_000) (map string_of_int @@ (1 -- 300_000))
|
|||
|
||||
q
|
||||
Q.(
|
||||
let p = small_list int in
|
||||
let p = list_small int in
|
||||
pair p p)
|
||||
(fun (l1, l2) ->
|
||||
if List.length l1 = List.length l2 then
|
||||
|
|
@ -315,7 +315,7 @@ q
|
|||
|
||||
q
|
||||
Q.(
|
||||
let p = small_list int in
|
||||
let p = list_small int in
|
||||
pair p p)
|
||||
(fun (l1, l2) ->
|
||||
let n = min (List.length l1) (List.length l2) in
|
||||
|
|
@ -351,14 +351,14 @@ combine_shortest (1 -- 100_001) (1 -- 100_000)
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(list_of_size Gen.(0 -- 10_000) (pair small_int small_string))
|
||||
Q.(list_size Gen.(0 -- 10_000) (pair nat_small string_small))
|
||||
(fun l ->
|
||||
let l1, l2 = split l in
|
||||
List.length l1 = List.length l && List.length l2 = List.length l)
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(list_of_size Gen.(0 -- 10_000) (pair small_int small_int))
|
||||
Q.(list_size Gen.(0 -- 10_000) (pair nat_small nat_small))
|
||||
(fun l -> split l = List.split l)
|
||||
|
||||
let cmp_lii_unord l1 l2 : bool =
|
||||
|
|
@ -392,12 +392,12 @@ eq
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(list_of_size Gen.(1 -- 4) (list_of_size Gen.(0 -- 4) small_int))
|
||||
Q.(list_size Gen.(1 -- 4) (list_size Gen.(0 -- 4) nat_small))
|
||||
(fun l -> cmp_lii_unord (cartesian_product l) (map_product_l CCFun.id l))
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair small_int (list small_int))
|
||||
Q.(pair nat_small (list nat_small))
|
||||
(fun (x, l) ->
|
||||
sorted_mem ~cmp:CCInt.compare x (List.sort CCInt.compare l)
|
||||
= mem ~eq:CCInt.equal x l)
|
||||
|
|
@ -433,14 +433,14 @@ equal CCInt.equal (sorted_diff ~cmp:CCInt.compare [ 2 ] [ 1; 2; 2; 2; 3 ]) []
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair (list small_int) (list small_int))
|
||||
Q.(pair (list nat_small) (list nat_small))
|
||||
(fun (l1, l2) ->
|
||||
List.length (sorted_merge ~cmp:CCInt.compare l1 l2)
|
||||
= List.length l1 + List.length l2)
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair (list small_int) (list small_int))
|
||||
Q.(pair (list nat_small) (list nat_small))
|
||||
(fun (l1, l2) ->
|
||||
let l =
|
||||
sorted_diff ~cmp:CCInt.compare
|
||||
|
|
@ -452,7 +452,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(triple small_nat small_nat int)
|
||||
Q.(triple nat_small nat_small int)
|
||||
(fun (n1, n2, x) ->
|
||||
let l =
|
||||
sorted_diff ~cmp:CCInt.compare
|
||||
|
|
@ -463,7 +463,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair (list small_int) (list small_int))
|
||||
Q.(pair (list nat_small) (list nat_small))
|
||||
(fun (l1, l2) ->
|
||||
let l1 = List.sort CCInt.compare l1 in
|
||||
let l2 = List.sort CCInt.compare l2 in
|
||||
|
|
@ -483,19 +483,19 @@ sort_uniq ~cmp:CCInt.compare [ 10; 10; 10; 10; 1; 10 ] = [ 1; 10 ]
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(list small_int)
|
||||
Q.(list nat_small)
|
||||
(fun l -> is_sorted ~cmp:CCInt.compare (List.sort Stdlib.compare l))
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair small_int (list small_int))
|
||||
Q.(pair nat_small (list nat_small))
|
||||
(fun (x, l) ->
|
||||
let l = List.sort Stdlib.compare l in
|
||||
is_sorted ~cmp:CCInt.compare (sorted_insert ~cmp:CCInt.compare x l))
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair small_int (list small_int))
|
||||
Q.(pair nat_small (list nat_small))
|
||||
(fun (x, l) ->
|
||||
let l = List.sort Stdlib.compare l in
|
||||
is_sorted ~cmp:CCInt.compare
|
||||
|
|
@ -503,7 +503,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair small_int (list small_int))
|
||||
Q.(pair nat_small (list nat_small))
|
||||
(fun (x, l) ->
|
||||
let l = List.sort Stdlib.compare l in
|
||||
is_sorted ~cmp:CCInt.compare
|
||||
|
|
@ -511,7 +511,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair small_int (list small_int))
|
||||
Q.(pair nat_small (list nat_small))
|
||||
(fun (x, l) ->
|
||||
let l = List.sort Stdlib.compare l in
|
||||
let l' = sorted_insert ~cmp:CCInt.compare ~uniq:false x l in
|
||||
|
|
@ -519,21 +519,21 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair small_int (list small_int))
|
||||
Q.(pair nat_small (list nat_small))
|
||||
(fun (x, l) ->
|
||||
let l = List.sort Stdlib.compare l in
|
||||
List.mem x (sorted_insert ~cmp:CCInt.compare x l))
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair small_int (list small_int))
|
||||
Q.(pair nat_small (list nat_small))
|
||||
(fun (x, l) ->
|
||||
let l = List.sort Stdlib.compare l in
|
||||
is_sorted ~cmp:CCInt.compare (sorted_remove ~cmp:CCInt.compare x l))
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair small_int (list small_int))
|
||||
Q.(pair nat_small (list nat_small))
|
||||
(fun (x, l) ->
|
||||
let l = List.sort Stdlib.compare l in
|
||||
is_sorted ~cmp:CCInt.compare
|
||||
|
|
@ -541,7 +541,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair small_int (list small_int))
|
||||
Q.(pair nat_small (list nat_small))
|
||||
(fun (x, l) ->
|
||||
let l = List.sort Stdlib.compare l in
|
||||
is_sorted ~cmp:CCInt.compare
|
||||
|
|
@ -549,7 +549,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair small_int (list small_int))
|
||||
Q.(pair nat_small (list nat_small))
|
||||
(fun (x, l) ->
|
||||
let l = List.sort Stdlib.compare l in
|
||||
let l' = sorted_remove ~cmp:CCInt.compare x l in
|
||||
|
|
@ -563,7 +563,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair small_int (list small_int))
|
||||
Q.(pair nat_small (list nat_small))
|
||||
(fun (x, l) ->
|
||||
let l = List.sort Stdlib.compare l in
|
||||
let l' = sorted_remove ~cmp:CCInt.compare ~all:true x l in
|
||||
|
|
@ -571,7 +571,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair small_int (list small_int))
|
||||
Q.(pair nat_small (list nat_small))
|
||||
(fun (x, l) ->
|
||||
let l = List.sort Stdlib.compare l in
|
||||
let l' = sorted_remove ~cmp:CCInt.compare ~all:false x l in
|
||||
|
|
@ -585,7 +585,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair small_int (list small_int))
|
||||
Q.(pair nat_small (list nat_small))
|
||||
(fun (x, l) ->
|
||||
let l = List.sort Stdlib.compare l in
|
||||
let l' = sorted_remove ~cmp:CCInt.compare x l in
|
||||
|
|
@ -599,7 +599,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair small_int (list small_int))
|
||||
Q.(pair nat_small (list nat_small))
|
||||
(fun (x, l) ->
|
||||
let l = List.sort Stdlib.compare l in
|
||||
let l' = sorted_remove ~cmp:CCInt.compare ~all:false x l in
|
||||
|
|
@ -613,7 +613,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair small_int (list small_int))
|
||||
Q.(pair nat_small (list nat_small))
|
||||
(fun (x, l) ->
|
||||
let l = List.sort Stdlib.compare l in
|
||||
not (List.mem x (sorted_remove ~cmp:CCInt.compare ~all:true x l)))
|
||||
|
|
@ -677,7 +677,7 @@ sorted_diff_uniq ~cmp:CCInt.compare
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair (list small_int) (list small_int))
|
||||
Q.(pair (list nat_small) (list nat_small))
|
||||
(fun (l1, l2) ->
|
||||
let l1 = List.sort CCInt.compare l1 in
|
||||
let l2 = List.sort CCInt.compare l2 in
|
||||
|
|
@ -685,7 +685,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair (list small_int) (list small_int))
|
||||
Q.(pair (list nat_small) (list nat_small))
|
||||
(fun (l1, l2) ->
|
||||
let l1 = List.sort CCInt.compare l1 in
|
||||
let l2 = List.sort CCInt.compare l2 in
|
||||
|
|
@ -699,7 +699,7 @@ t @@ fun () -> take 10_000 (range 0 2_000) = range 0 2_000;;
|
|||
t @@ fun () -> take 300_000 (1 -- 400_000) = 1 -- 300_000;;
|
||||
|
||||
q
|
||||
(Q.pair (Q.list Q.small_int) Q.int)
|
||||
(Q.pair (Q.list Q.nat_small) Q.int)
|
||||
(fun (l, i) ->
|
||||
let i = abs i in
|
||||
let l1 = take i l in
|
||||
|
|
@ -716,7 +716,7 @@ with Failure _ -> true
|
|||
t @@ fun () -> hd_tl [ 1; 2; 3 ] = (1, [ 2; 3 ]);;
|
||||
|
||||
q
|
||||
(Q.pair (Q.list Q.small_int) Q.int)
|
||||
(Q.pair (Q.list Q.nat_small) Q.int)
|
||||
(fun (l, i) ->
|
||||
let i = abs i in
|
||||
let l1, l2 = take_drop i l in
|
||||
|
|
@ -724,7 +724,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
(Q.pair (Q.list Q.small_int) Q.int)
|
||||
(Q.pair (Q.list Q.nat_small) Q.int)
|
||||
(fun (l, i) ->
|
||||
let i = abs i in
|
||||
take_drop i l = (take i l, drop i l))
|
||||
|
|
@ -771,11 +771,11 @@ eq
|
|||
(subs 2 [ 1; 2; 3; 4; 5 ])
|
||||
;;
|
||||
|
||||
q Q.(small_list small_int) (fun l -> l = (chunks 3 l |> List.flatten));;
|
||||
q Q.(small_list small_int) (fun l -> l = (chunks 5 l |> List.flatten));;
|
||||
q Q.(list_small nat_small) (fun l -> l = (chunks 3 l |> List.flatten));;
|
||||
q Q.(list_small nat_small) (fun l -> l = (chunks 5 l |> List.flatten));;
|
||||
|
||||
q
|
||||
Q.(small_list small_int)
|
||||
Q.(list_small nat_small)
|
||||
(fun l -> List.for_all (fun u -> List.length u <= 5) (chunks 5 l))
|
||||
;;
|
||||
|
||||
|
|
@ -803,12 +803,12 @@ eq [ 1; 2; 3; 4; 5 ] (interleave [ 1; 3 ] [ 2; 4; 5 ]);;
|
|||
eq [ 1; 2; 3 ] (interleave [ 1 ] [ 2; 3 ]);;
|
||||
|
||||
q
|
||||
Q.(pair (small_list int) (small_list int))
|
||||
Q.(pair (list_small int) (list_small int))
|
||||
(fun (l1, l2) -> length (interleave l1 l2) = length l1 + length l2)
|
||||
;;
|
||||
|
||||
q Q.(small_list int) (fun l -> l = interleave [] l);;
|
||||
q Q.(small_list int) (fun l -> l = interleave l []);;
|
||||
q Q.(list_small int) (fun l -> l = interleave [] l);;
|
||||
q Q.(list_small int) (fun l -> l = interleave l []);;
|
||||
t @@ fun () -> take_while (fun x -> x < 10) (1 -- 20) = 1 -- 9;;
|
||||
t @@ fun () -> take_while (fun x -> x <> 0) [ 0; 1; 2; 3 ] = [];;
|
||||
t @@ fun () -> take_while (fun _ -> true) [] = [];;
|
||||
|
|
@ -816,19 +816,19 @@ t @@ fun () -> take_while (fun _ -> true) (1 -- 10) = 1 -- 10;;
|
|||
t @@ fun () -> take_while (fun _ -> true) (1 -- 300_000) = 1 -- 300_000;;
|
||||
|
||||
q
|
||||
Q.(pair (fun1 Observable.int bool) (list small_int))
|
||||
Q.(pair (fun1 Observable.int bool) (list nat_small))
|
||||
(fun (f, l) ->
|
||||
let l1 = take_while (Q.Fn.apply f) l in
|
||||
List.for_all (Q.Fn.apply f) l1)
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair (fun1 Observable.int bool) (list small_int))
|
||||
Q.(pair (fun1 Observable.int bool) (list nat_small))
|
||||
(fun (f, l) -> take_while (Q.Fn.apply f) l @ drop_while (Q.Fn.apply f) l = l)
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair (fun1 Observable.int bool) (list small_int))
|
||||
Q.(pair (fun1 Observable.int bool) (list nat_small))
|
||||
(fun (f, l) ->
|
||||
let l1, l2 = take_drop_while (Q.Fn.apply f) l in
|
||||
l1 = take_while (Q.Fn.apply f) l && l2 = drop_while (Q.Fn.apply f) l)
|
||||
|
|
@ -934,7 +934,7 @@ eq
|
|||
eq (Ok []) (all_ok []);;
|
||||
eq (Ok [ 1; 2; 3 ]) (all_ok [ Ok 1; Ok 2; Ok 3 ]);;
|
||||
eq (Error "e2") (all_ok [ Ok 1; Error "e2"; Error "e3"; Ok 4 ]);;
|
||||
q Q.(small_list small_int) (fun l -> mem 1 l = List.mem 1 l);;
|
||||
q Q.(list_small nat_small) (fun l -> mem 1 l = List.mem 1 l);;
|
||||
|
||||
q
|
||||
Q.(pair int (list int))
|
||||
|
|
@ -966,7 +966,7 @@ uniq ~eq:CCInt.equal [ 1; 1; 2; 2; 3; 4; 4; 2; 4; 1; 5 ]
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(small_list small_int)
|
||||
Q.(list_small nat_small)
|
||||
(fun l ->
|
||||
sort_uniq ~cmp:CCInt.compare l
|
||||
= (uniq ~eq:CCInt.equal l |> sort Stdlib.compare))
|
||||
|
|
@ -1014,7 +1014,7 @@ t @@ fun () -> range_by ~step:~-2 5 0 = [ 5; 3; 1 ];;
|
|||
t @@ fun () -> range_by ~step:max_int 0 2 = [ 0 ];;
|
||||
|
||||
q
|
||||
Q.(pair small_int small_int)
|
||||
Q.(pair nat_small nat_small)
|
||||
(fun (i, j) ->
|
||||
let i = min i j and j = max i j in
|
||||
range_by ~step:1 i j = range i j)
|
||||
|
|
@ -1030,7 +1030,7 @@ t @@ fun () -> append (range 0 100) (range 101 1000) = range 0 1000;;
|
|||
t @@ fun () -> append (range 1000 501) (range 500 0) = range 1000 0;;
|
||||
|
||||
q
|
||||
Q.(pair small_int small_int)
|
||||
Q.(pair nat_small nat_small)
|
||||
(fun (a, b) ->
|
||||
let l = a --^ b in
|
||||
not (List.mem b l))
|
||||
|
|
@ -1039,7 +1039,7 @@ q
|
|||
t @@ fun () -> repeat 2 [ 1; 2; 3 ] = [ 1; 2; 3; 1; 2; 3 ];;
|
||||
|
||||
q
|
||||
Q.(pair small_int (small_list int))
|
||||
Q.(pair nat_small (list_small int))
|
||||
(fun (n, l) ->
|
||||
if n > 0 then
|
||||
repeat n l = flat_map (fun _ -> l) (1 -- n)
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@ eq'
|
|||
module M2 = Make (CCInt);;
|
||||
|
||||
q
|
||||
Q.(list (pair small_int small_int))
|
||||
Q.(list (pair nat_small nat_small))
|
||||
M2.(
|
||||
fun l -> to_list (of_list l) = to_list (of_list_with ~f:(fun _ v _ -> v) l))
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(list (pair small_int small_int))
|
||||
Q.(list (pair nat_small nat_small))
|
||||
M2.(
|
||||
fun l ->
|
||||
to_list (of_iter @@ Iter.of_list l)
|
||||
|
|
@ -30,7 +30,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(list (pair small_int small_int))
|
||||
Q.(list (pair nat_small nat_small))
|
||||
M2.(
|
||||
fun l ->
|
||||
to_list (of_seq @@ CCSeq.of_list l)
|
||||
|
|
|
|||
|
|
@ -39,14 +39,14 @@ with Division_by_zero -> true
|
|||
;;
|
||||
|
||||
q
|
||||
(Q.pair (Q.map of_int Q.small_signed_int) (Q.map of_int Q.small_nat))
|
||||
(Q.pair (Q.map of_int Q.int_small) (Q.map of_int Q.nat_small))
|
||||
(fun (n, m) ->
|
||||
let m = m + 1n in
|
||||
floor_div n m = of_float @@ floor (to_float n /. to_float m))
|
||||
;;
|
||||
|
||||
q
|
||||
(Q.pair (Q.map of_int Q.small_signed_int) (Q.map of_int Q.small_nat))
|
||||
(Q.pair (Q.map of_int Q.int_small) (Q.map of_int Q.nat_small))
|
||||
(fun (n, m) ->
|
||||
let m = m + 1n in
|
||||
floor_div n (-m) = of_float @@ floor (to_float n /. to_float (-m)))
|
||||
|
|
@ -73,7 +73,7 @@ eq' [ 5n; 3n; 1n ] (range_by ~step:(neg 2n) 5n 0n |> Iter.to_list);;
|
|||
eq' [ 0n ] (range_by ~step:max_int 0n 2n |> Iter.to_list);;
|
||||
|
||||
q
|
||||
Q.(pair (map of_int small_int) (map of_int small_int))
|
||||
Q.(pair (map of_int nat_small) (map of_int nat_small))
|
||||
(fun (i, j) ->
|
||||
let i = min i j and j = max i j in
|
||||
CCList.equal CCNativeint.equal
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ eq
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(printable_string)
|
||||
Q.(string_printable)
|
||||
(fun s ->
|
||||
let pred = function
|
||||
| 'a' .. 'z' | 'A' .. 'Z' | '{' | '}' -> true
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ open CCRandom
|
|||
module T = (val Containers_testlib.make ~__FILE__ ())
|
||||
include T;;
|
||||
|
||||
q Q.(list small_int) (fun l -> l = [] || List.mem (run (pick_list l)) l);;
|
||||
q Q.(list nat_small) (fun l -> l = [] || List.mem (run (pick_list l)) l);;
|
||||
|
||||
q
|
||||
Q.(pair small_int small_int)
|
||||
Q.(pair nat_small nat_small)
|
||||
(fun (i, j) ->
|
||||
let len, n = 2 + min i j, max i j in
|
||||
let l = QCheck.Gen.generate1 (split_list n ~len) in
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ of_list [ 1; 2; 3; 4 ] |> take_while (fun x -> x < 4) |> to_list = [ 1; 2; 3 ]
|
|||
;;
|
||||
|
||||
q
|
||||
(Q.pair (Q.list Q.small_int) Q.small_int)
|
||||
(Q.pair (Q.list Q.nat_small) Q.nat_small)
|
||||
(fun (l, n) ->
|
||||
let s = of_list l in
|
||||
let s1, s2 = take n s, drop n s in
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ let sexp_gen =
|
|||
match n with
|
||||
| 0 -> atom st
|
||||
| _ ->
|
||||
frequency
|
||||
oneof_weighted
|
||||
[
|
||||
1, atom; 2, map mklist (list_size (0 -- 10) (self (n / 10)));
|
||||
]
|
||||
|
|
@ -154,7 +154,7 @@ let gen_csexp (str : string Q.Gen.t) : CS0.t Q.Gen.t =
|
|||
let open Csexp in
|
||||
( fix @@ fun self depth ->
|
||||
let mklist n = list_size (0 -- n) (self (depth + 1)) >|= fun l -> List l in
|
||||
frequency
|
||||
oneof_weighted
|
||||
@@ List.flatten
|
||||
[
|
||||
[ (3, str >|= fun s -> Atom s) ];
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ include T
|
|||
open CCString
|
||||
open Stdlib;;
|
||||
|
||||
q Q.printable_string (fun s -> s = rev (rev s));;
|
||||
q Q.printable_string (fun s -> length s = length (rev s));;
|
||||
q Q.printable_string (fun s -> rev s = (to_list s |> List.rev |> of_list));;
|
||||
q Q.string_printable (fun s -> s = rev (rev s));;
|
||||
q Q.string_printable (fun s -> length s = length (rev s));;
|
||||
q Q.string_printable (fun s -> rev s = (to_list s |> List.rev |> of_list));;
|
||||
eq "abc" (rev "cba");;
|
||||
eq "" (rev "");;
|
||||
eq " " (rev " ")
|
||||
|
|
@ -18,7 +18,7 @@ eq' 1 (find ~sub:"a" "_a_a_a_");;
|
|||
eq' 6 (find ~start:5 ~sub:"a" "a1a234a");;
|
||||
|
||||
q ~count:10_000
|
||||
Q.(pair printable_string printable_string)
|
||||
Q.(pair string_printable string_printable)
|
||||
(fun (s1, s2) ->
|
||||
let i = find ~sub:s2 s1 in
|
||||
i < 0 || String.sub s1 i (length s2) = s2)
|
||||
|
|
@ -45,7 +45,7 @@ eq' 4 (rfind ~sub:"bc" "abcdbcd");;
|
|||
eq' 6 (rfind ~sub:"a" "a1a234a");;
|
||||
|
||||
q ~count:10_000
|
||||
Q.(pair printable_string printable_string)
|
||||
Q.(pair string_printable string_printable)
|
||||
(fun (s1, s2) ->
|
||||
let i = rfind ~sub:s2 s1 in
|
||||
i < 0 || String.sub s1 i (length s2) = s2)
|
||||
|
|
@ -102,7 +102,7 @@ eq
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(printable_string)
|
||||
Q.(string_printable)
|
||||
(fun s ->
|
||||
let s = split_on_char ' ' s |> String.concat " " in
|
||||
s = (split_on_char ' ' s |> String.concat " "))
|
||||
|
|
@ -116,7 +116,7 @@ t @@ fun () -> compare_versions "0.foo" "0.0" < 0;;
|
|||
t @@ fun () -> compare_versions "1.2.3.4" "01.2.4.3" < 0;;
|
||||
|
||||
q
|
||||
Q.(pair printable_string printable_string)
|
||||
Q.(pair string_printable string_printable)
|
||||
(fun (a, b) ->
|
||||
CCOrd.equiv (compare_versions a b) (CCOrd.opp compare_versions b a))
|
||||
;;
|
||||
|
|
@ -130,14 +130,14 @@ t @@ fun () -> compare_natural "foo1a1" "foo1a2" < 0;;
|
|||
t @@ fun () -> compare_natural "foo1a17" "foo1a2" > 0;;
|
||||
|
||||
q
|
||||
Q.(pair printable_string printable_string)
|
||||
Q.(pair string_printable string_printable)
|
||||
(fun (a, b) -> CCOrd.opp compare_natural a b = compare_natural b a)
|
||||
;;
|
||||
|
||||
q Q.(printable_string) (fun a -> compare_natural a a = 0);;
|
||||
q Q.(string_printable) (fun a -> compare_natural a a = 0);;
|
||||
|
||||
q
|
||||
Q.(triple printable_string printable_string printable_string)
|
||||
Q.(triple string_printable string_printable string_printable)
|
||||
(fun (a, b, c) ->
|
||||
if compare_natural a b < 0 && compare_natural b c < 0 then
|
||||
compare_natural a c < 0
|
||||
|
|
@ -145,18 +145,18 @@ q
|
|||
Q.assume_fail ())
|
||||
;;
|
||||
|
||||
q Q.(string_of_size Gen.(0 -- 30)) (fun s -> edit_distance s s = 0);;
|
||||
q Q.(string_size Gen.(0 -- 30)) (fun s -> edit_distance s s = 0);;
|
||||
|
||||
q
|
||||
Q.(
|
||||
let p = string_of_size Gen.(0 -- 20) in
|
||||
let p = string_size Gen.(0 -- 20) in
|
||||
pair p p)
|
||||
(fun (s1, s2) -> edit_distance s1 s2 = edit_distance s2 s1)
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(
|
||||
let p = string_of_size Gen.(0 -- 20) in
|
||||
let p = string_size Gen.(0 -- 20) in
|
||||
pair p p)
|
||||
(fun (s1, s2) ->
|
||||
let e = edit_distance s1 s2 in
|
||||
|
|
@ -232,7 +232,7 @@ eq ("abc", "") (take_drop 3 "abc");;
|
|||
eq ("abc", "") (take_drop 5 "abc");;
|
||||
|
||||
q
|
||||
Q.(printable_string)
|
||||
Q.(string_printable)
|
||||
(fun s ->
|
||||
let predicate c = Char.code c mod 2 = 0 in
|
||||
let prefix = take_while predicate s in
|
||||
|
|
@ -243,7 +243,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(printable_string)
|
||||
Q.(string_printable)
|
||||
(fun s ->
|
||||
let predicate c = Char.code c mod 2 = 0 in
|
||||
let prefix = rdrop_while predicate s in
|
||||
|
|
@ -279,28 +279,28 @@ eq' [ "ab"; "c" ] (lines "ab\nc\n");;
|
|||
eq' [] (lines "");;
|
||||
eq' [ "" ] (lines "\n");;
|
||||
eq' [ ""; "a" ] (lines "\na");;
|
||||
q Q.(printable_string) (fun s -> lines s = (lines_gen s |> Gen.to_list));;
|
||||
q Q.(printable_string) (fun s -> lines s = (lines_iter s |> Iter.to_list));;
|
||||
q Q.(string_printable) (fun s -> lines s = (lines_gen s |> Gen.to_list));;
|
||||
q Q.(string_printable) (fun s -> lines s = (lines_iter s |> Iter.to_list));;
|
||||
|
||||
q
|
||||
Q.(small_list printable_string)
|
||||
Q.(list_small string_printable)
|
||||
(fun l -> concat_iter ~sep:"\n" (Iter.of_list l) = concat "\n" l)
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(small_list printable_string)
|
||||
Q.(list_small string_printable)
|
||||
(fun l -> concat_gen ~sep:"\n" (Gen.of_list l) = concat "\n" l)
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(small_list printable_string)
|
||||
Q.(list_small string_printable)
|
||||
(fun l -> concat_seq ~sep:"\n" (CCSeq.of_list l) = concat "\n" l)
|
||||
;;
|
||||
|
||||
eq ~printer:CCFun.id "" (unlines []);;
|
||||
eq ~printer:CCFun.id "ab\nc\n" (unlines [ "ab"; "c" ]);;
|
||||
q Q.printable_string (fun s -> trim (unlines (lines s)) = trim s);;
|
||||
q Q.printable_string (fun s -> trim (unlines_gen (lines_gen s)) = trim s);;
|
||||
q Q.string_printable (fun s -> trim (unlines (lines s)) = trim s);;
|
||||
q Q.string_printable (fun s -> trim (unlines_gen (lines_gen s)) = trim s);;
|
||||
eq ~printer:CCFun.id "" (take_while (Char.equal 'c') "heloo_cc");;
|
||||
eq ~printer:CCFun.id "" (take_while (Char.equal 'c') "");;
|
||||
eq ~printer:CCFun.id "c" (take_while (Char.equal 'c') "c");;
|
||||
|
|
@ -320,7 +320,7 @@ eq ~printer:CCFun.id "ANTED"
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(small_list small_string)
|
||||
Q.(list_small string_small)
|
||||
(fun l ->
|
||||
let l = unlines l |> lines in
|
||||
l = (unlines l |> lines))
|
||||
|
|
@ -352,16 +352,16 @@ eq ~printer:Q.Print.string "abde"
|
|||
"abcdec")
|
||||
;;
|
||||
|
||||
q Q.printable_string (fun s -> filter (fun _ -> true) s = s);;
|
||||
q Q.string_printable (fun s -> filter (fun _ -> true) s = s);;
|
||||
eq ~printer:Q.Print.string "abcde" (uniq Stdlib.( = ) "abbccdeeeee");;
|
||||
eq ~printer:CCFun.id "abc " (ltrim " abc ");;
|
||||
eq ~printer:CCFun.id " abc" (rtrim " abc ");;
|
||||
q Q.(printable_string) (fun s -> String.trim s = (s |> ltrim |> rtrim));;
|
||||
q Q.(printable_string) (fun s -> ltrim s = ltrim (ltrim s));;
|
||||
q Q.(printable_string) (fun s -> rtrim s = rtrim (rtrim s));;
|
||||
q Q.(string_printable) (fun s -> String.trim s = (s |> ltrim |> rtrim));;
|
||||
q Q.(string_printable) (fun s -> ltrim s = ltrim (ltrim s));;
|
||||
q Q.(string_printable) (fun s -> rtrim s = rtrim (rtrim s));;
|
||||
|
||||
q
|
||||
Q.(printable_string)
|
||||
Q.(string_printable)
|
||||
(fun s ->
|
||||
let s' = ltrim s in
|
||||
if s' = "" then
|
||||
|
|
@ -371,7 +371,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(printable_string)
|
||||
Q.(string_printable)
|
||||
(fun s ->
|
||||
let s' = rtrim s in
|
||||
if s' = "" then
|
||||
|
|
@ -384,13 +384,13 @@ t @@ fun () -> equal_caseless "foo" "FoO";;
|
|||
t @@ fun () -> equal_caseless "helLo" "HEllO";;
|
||||
|
||||
q
|
||||
Q.(pair printable_string printable_string)
|
||||
Q.(pair string_printable string_printable)
|
||||
(fun (s1, s2) ->
|
||||
equal_caseless s1 s2 = (lowercase_ascii s1 = lowercase_ascii s2))
|
||||
;;
|
||||
|
||||
q Q.(printable_string) (fun s -> equal_caseless s s);;
|
||||
q Q.(printable_string) (fun s -> equal_caseless (uppercase_ascii s) s)
|
||||
q Q.(string_printable) (fun s -> equal_caseless s s);;
|
||||
q Q.(string_printable) (fun s -> equal_caseless (uppercase_ascii s) s)
|
||||
|
||||
let eq' = eq ~printer:(Printf.sprintf "%S");;
|
||||
|
||||
|
|
|
|||
|
|
@ -63,12 +63,12 @@ assert_equal ~cmp:equal ~printer s s';
|
|||
true
|
||||
;;
|
||||
|
||||
q Q.small_string (fun s ->
|
||||
q Q.string_small (fun s ->
|
||||
Q.assume (CCString.for_all (fun c -> Char.code c < 128) s);
|
||||
is_valid s)
|
||||
;;
|
||||
|
||||
q ~long_factor:10 Q.small_string (fun s ->
|
||||
q ~long_factor:10 Q.string_small (fun s ->
|
||||
Q.assume (CCString.for_all (fun c -> Char.code c < 128) s);
|
||||
s = (of_string_exn s |> to_iter |> of_iter |> to_string))
|
||||
;;
|
||||
|
|
@ -79,21 +79,21 @@ q ~long_factor:10 Q.string (fun s ->
|
|||
;;
|
||||
|
||||
q ~long_factor:10 ~count:20_000
|
||||
Q.(small_list arb_uchar)
|
||||
Q.(list_small arb_uchar)
|
||||
(fun l ->
|
||||
let s = of_list l in
|
||||
l = to_list s)
|
||||
;;
|
||||
|
||||
q ~long_factor:10
|
||||
Q.(small_list arb_uchar)
|
||||
Q.(list_small arb_uchar)
|
||||
(fun l ->
|
||||
let s = of_list l in
|
||||
l = to_list @@ of_gen @@ to_gen s)
|
||||
;;
|
||||
|
||||
q ~long_factor:10
|
||||
Q.(small_list arb_uchar)
|
||||
Q.(list_small arb_uchar)
|
||||
(fun l ->
|
||||
let s = of_list l in
|
||||
l = to_list @@ of_iter @@ to_iter s)
|
||||
|
|
@ -127,7 +127,7 @@ q ~long_factor:40 Q.string (fun s ->
|
|||
|
||||
(* compare with uutf *)
|
||||
|
||||
q ~long_factor:40 ~count:50_000 Q.small_string (fun s ->
|
||||
q ~long_factor:40 ~count:50_000 Q.string_small (fun s ->
|
||||
let v1 = is_valid s in
|
||||
let v2 = uutf_is_valid s in
|
||||
if v1 = v2 then
|
||||
|
|
@ -137,7 +137,7 @@ q ~long_factor:40 ~count:50_000 Q.small_string (fun s ->
|
|||
;;
|
||||
|
||||
q ~long_factor:40 ~count:50_000
|
||||
Q.(small_list arb_uchar)
|
||||
Q.(list_small arb_uchar)
|
||||
(fun l ->
|
||||
let pp s = Q.Print.(list pp_uchar) s in
|
||||
let uutf = uutf_of_l l in
|
||||
|
|
@ -148,7 +148,7 @@ q ~long_factor:40 ~count:50_000
|
|||
Q.Test.fail_reportf "l: '%s', uutf: '%s', containers: '%s'" (pp l) uutf s)
|
||||
;;
|
||||
|
||||
q ~long_factor:40 ~count:50_000 Q.small_string (fun s ->
|
||||
q ~long_factor:40 ~count:50_000 Q.string_small (fun s ->
|
||||
Q.assume (is_valid s && uutf_is_valid s);
|
||||
let pp s = Q.Print.(list pp_uchar) s in
|
||||
let l_uutf = uutf_to_iter s |> Iter.to_list in
|
||||
|
|
@ -170,10 +170,10 @@ true
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(small_list arb_uchar)
|
||||
Q.(list_small arb_uchar)
|
||||
(fun l -> of_list l = concat empty (List.map of_uchar l))
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair small_nat arb_uchar)
|
||||
Q.(pair nat_small arb_uchar)
|
||||
(fun (i, c) -> make i c = concat empty (CCList.init i (fun _ -> of_uchar c)))
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ true
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(list_of_size (Gen.int_range 10 10) small_int)
|
||||
Q.(list_size (Gen.int_range 10 10) nat_small)
|
||||
(fun l ->
|
||||
let v1 = of_list l and v2 = of_list l in
|
||||
remove_and_shift v1 9;
|
||||
|
|
@ -278,7 +278,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(list_of_size (Gen.int_range 10 10) small_int)
|
||||
Q.(list_size (Gen.int_range 10 10) nat_small)
|
||||
(fun l ->
|
||||
let l = List.sort CCInt.compare l in
|
||||
let v = of_list l in
|
||||
|
|
@ -287,7 +287,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(list_of_size (Gen.int_range 10 10) small_int)
|
||||
Q.(list_size (Gen.int_range 10 10) nat_small)
|
||||
(fun l ->
|
||||
let l = List.sort CCInt.compare l in
|
||||
let v1 = of_list l and v2 = of_list l in
|
||||
|
|
@ -407,13 +407,13 @@ t @@ fun () -> not (equal ( = ) (return 42) (create ()));;
|
|||
|
||||
q
|
||||
Q.(
|
||||
let g = list_of_size Gen.(0 -- 10) small_int in
|
||||
let g = list_size Gen.(0 -- 10) nat_small in
|
||||
pair g g)
|
||||
(fun (l1, l2) -> equal ( = ) (of_list l1) (of_list l2) = (l1 = l2))
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair (small_list small_int) (small_list small_int))
|
||||
Q.(pair (list_small nat_small) (list_small nat_small))
|
||||
(fun (l1, l2) ->
|
||||
let v1 = of_list l1 in
|
||||
let v2 = of_list l2 in
|
||||
|
|
@ -421,7 +421,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair (small_list small_int) (small_list small_int))
|
||||
Q.(pair (list_small nat_small) (list_small nat_small))
|
||||
(fun (l1, l2) ->
|
||||
let v1 = of_list l1 in
|
||||
let v2 = of_list l2 in
|
||||
|
|
@ -452,7 +452,7 @@ true
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(small_list small_int)
|
||||
Q.(list_small nat_small)
|
||||
(fun l ->
|
||||
let v = of_list l in
|
||||
let v' = copy v in
|
||||
|
|
@ -466,7 +466,7 @@ assert_equal [ 1; 2; 3; 4; 5 ] (to_list v);
|
|||
true
|
||||
;;
|
||||
|
||||
q (gen Q.small_int) (fun v ->
|
||||
q (gen Q.nat_small) (fun v ->
|
||||
let n = size v / 2 in
|
||||
let l = to_list v in
|
||||
let h = Iter.(to_list (take n (of_list l))) in
|
||||
|
|
@ -475,13 +475,13 @@ q (gen Q.small_int) (fun v ->
|
|||
h = to_list v')
|
||||
;;
|
||||
|
||||
q (gen Q.small_int) (fun v ->
|
||||
q (gen Q.nat_small) (fun v ->
|
||||
let v' = copy v in
|
||||
shrink_to_fit v;
|
||||
to_list v = to_list v')
|
||||
;;
|
||||
|
||||
q (gen Q.small_int) (fun v ->
|
||||
q (gen Q.nat_small) (fun v ->
|
||||
let v' = copy v in
|
||||
sort' Stdlib.compare v';
|
||||
let l = to_list v' in
|
||||
|
|
@ -495,7 +495,7 @@ to_list v = [ 1; 2; 3; 4; 5 ]
|
|||
;;
|
||||
|
||||
q ~long_factor:10
|
||||
Q.(small_list small_int)
|
||||
Q.(list_small nat_small)
|
||||
(fun l ->
|
||||
let v = of_list l in
|
||||
uniq_sort Stdlib.compare v;
|
||||
|
|
@ -517,7 +517,7 @@ to_list (map string_of_int v) = [ "1"; "2"; "3" ]
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair (fun1 Observable.int small_int) (small_list small_int))
|
||||
Q.(pair (fun1 Observable.int nat_small) (list_small nat_small))
|
||||
(fun (Q.Fun (_, f), l) ->
|
||||
let v = of_list l in
|
||||
to_list (map f v) = List.map f l)
|
||||
|
|
@ -533,14 +533,14 @@ to_list (mapi (fun i e -> Printf.sprintf "%i %i" i e) v)
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair (fun2 Observable.int Observable.int small_int) (small_list small_int))
|
||||
Q.(pair (fun2 Observable.int Observable.int nat_small) (list_small nat_small))
|
||||
(fun (Q.Fun (_, f), l) ->
|
||||
let v = of_list l in
|
||||
to_list (mapi f v) = List.mapi f l)
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair (fun1 Observable.int small_int) (small_list small_int))
|
||||
Q.(pair (fun1 Observable.int nat_small) (list_small nat_small))
|
||||
(fun (Q.Fun (_, f), l) ->
|
||||
let v = of_list l in
|
||||
map_in_place f v;
|
||||
|
|
@ -554,7 +554,7 @@ to_list v = [ 1; 2; 3 ]
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair (fun1 Observable.int bool) (small_list small_int))
|
||||
Q.(pair (fun1 Observable.int bool) (list_small nat_small))
|
||||
(fun (Q.Fun (_, f), l) ->
|
||||
let v = of_list l in
|
||||
filter_in_place f v;
|
||||
|
|
@ -570,7 +570,7 @@ filter (fun x -> x mod 2 = 0) (1 -- 1_000_000) |> length = 500_000
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair (fun1 Observable.int bool) (small_list small_int))
|
||||
Q.(pair (fun1 Observable.int bool) (list_small nat_small))
|
||||
(fun (Q.Fun (_, f), l) ->
|
||||
let v = of_list l in
|
||||
to_list (filter f v) = List.filter f l)
|
||||
|
|
@ -580,35 +580,35 @@ t @@ fun () -> fold ( + ) 0 (of_list [ 1; 2; 3; 4; 5 ]) = 15;;
|
|||
t @@ fun () -> fold ( + ) 0 (create ()) = 0;;
|
||||
|
||||
q
|
||||
Q.(pair (fun2 Observable.int Observable.int small_int) (small_list small_int))
|
||||
Q.(pair (fun2 Observable.int Observable.int nat_small) (list_small nat_small))
|
||||
(fun (Q.Fun (_, f), l) ->
|
||||
let v = of_list l in
|
||||
fold f 0 v = List.fold_left f 0 l)
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair (fun1 Observable.int bool) (small_list small_int))
|
||||
Q.(pair (fun1 Observable.int bool) (list_small nat_small))
|
||||
(fun (Q.Fun (_, f), l) ->
|
||||
let v = of_list l in
|
||||
exists f v = List.exists f l)
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair (fun1 Observable.int bool) (small_list small_int))
|
||||
Q.(pair (fun1 Observable.int bool) (list_small nat_small))
|
||||
(fun (Q.Fun (_, f), l) ->
|
||||
let v = of_list l in
|
||||
for_all f v = List.for_all f l)
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair (fun1 Observable.int bool) (small_list small_int))
|
||||
Q.(pair (fun1 Observable.int bool) (list_small nat_small))
|
||||
(fun (Q.Fun (_, f), l) ->
|
||||
let v = of_list l in
|
||||
find f v = CCList.find_pred f l)
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(list small_int)
|
||||
Q.(list nat_small)
|
||||
(fun l ->
|
||||
let v = of_list l in
|
||||
let f x = x > 30 && x < 35 in
|
||||
|
|
@ -623,14 +623,14 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair (fun1 Observable.int (option bool)) (small_list small_int))
|
||||
Q.(pair (fun1 Observable.int (option bool)) (list_small nat_small))
|
||||
(fun (Q.Fun (_, f), l) ->
|
||||
let v = of_list l in
|
||||
to_list (filter_map f v) = CCList.filter_map f l)
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair (fun1 Observable.int (option small_int)) (small_list small_int))
|
||||
Q.(pair (fun1 Observable.int (option nat_small)) (list_small nat_small))
|
||||
(fun (Q.Fun (_, f), l) ->
|
||||
let v = of_list l in
|
||||
filter_map_in_place f v;
|
||||
|
|
@ -668,7 +668,7 @@ eq ~cmp:( = )
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(small_list small_int)
|
||||
Q.(list_small nat_small)
|
||||
(fun l ->
|
||||
let v = of_list l in
|
||||
rev_in_place v;
|
||||
|
|
@ -680,7 +680,7 @@ t @@ fun () -> rev (of_list [ 1; 2; 3; 4; 5 ]) |> to_list = [ 5; 4; 3; 2; 1 ];;
|
|||
t @@ fun () -> rev (create ()) |> to_list = [];;
|
||||
|
||||
q
|
||||
Q.(small_list small_int)
|
||||
Q.(list_small nat_small)
|
||||
(fun l ->
|
||||
let v = of_list l in
|
||||
to_list (rev v) = List.rev l)
|
||||
|
|
@ -724,12 +724,12 @@ t @@ fun () -> 4 -- 1 |> to_list = [ 4; 3; 2; 1 ];;
|
|||
t @@ fun () -> 0 -- 0 |> to_list = [ 0 ];;
|
||||
|
||||
q
|
||||
Q.(pair small_int small_int)
|
||||
Q.(pair nat_small nat_small)
|
||||
(fun (a, b) -> a -- b |> to_list = CCList.(a -- b))
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair small_int small_int)
|
||||
Q.(pair nat_small nat_small)
|
||||
(fun (a, b) -> a --^ b |> to_list = CCList.(a --^ b))
|
||||
;;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ let ppli = CCFormat.(Dump.list int)
|
|||
|
||||
module Intset = CCSet.Make (CCInt);;
|
||||
|
||||
q (Q.pair Q.small_int Q.bool) (fun (size, b) -> create ~size b |> length = size)
|
||||
q (Q.pair Q.nat_small Q.bool) (fun (size, b) -> create ~size b |> length = size)
|
||||
;;
|
||||
|
||||
t ~name:(spf "line %d" __LINE__) @@ fun () ->
|
||||
|
|
@ -31,14 +31,14 @@ t ~name:(spf "line %d" __LINE__) @@ fun () ->
|
|||
create ~size:29 true |> to_sorted_list = CCList.range 0 28
|
||||
;;
|
||||
|
||||
q (Q.list Q.small_int) (fun l ->
|
||||
q (Q.list Q.nat_small) (fun l ->
|
||||
let bv = of_list l in
|
||||
to_list bv = to_list (copy bv))
|
||||
;;
|
||||
|
||||
q Q.small_int (fun size -> create ~size true |> cardinal = size);;
|
||||
q Q.nat_small (fun size -> create ~size true |> cardinal = size);;
|
||||
|
||||
q Q.small_int (fun size ->
|
||||
q Q.nat_small (fun size ->
|
||||
create ~size true |> to_sorted_list = CCList.init size CCFun.id)
|
||||
;;
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ assert_equal ~printer:string_of_int 87 (CCBV.cardinal bv1);
|
|||
true
|
||||
;;
|
||||
|
||||
q Q.small_int (fun n -> CCBV.cardinal (CCBV.create ~size:n true) = n);;
|
||||
q Q.nat_small (fun n -> CCBV.cardinal (CCBV.create ~size:n true) = n);;
|
||||
|
||||
t ~name:(spf "line %d" __LINE__) @@ fun () ->
|
||||
let bv = CCBV.create ~size:99 false in
|
||||
|
|
@ -169,7 +169,7 @@ eq'
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(small_int)
|
||||
Q.(nat_small)
|
||||
(fun n ->
|
||||
assert (n >= 0);
|
||||
let bv = create ~size:n true in
|
||||
|
|
@ -208,7 +208,7 @@ eq ~printer:(CCFormat.to_string ppli) [ 1; 2; 3; 4; 64; 130 ]
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(small_list small_nat)
|
||||
Q.(list_small nat_small)
|
||||
(fun l ->
|
||||
let l = List.sort_uniq CCOrd.poly l in
|
||||
let l2 = of_list l |> to_sorted_list in
|
||||
|
|
@ -219,7 +219,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(small_list small_nat)
|
||||
Q.(list_small nat_small)
|
||||
(fun l ->
|
||||
let bv = of_list l in
|
||||
let l1 = bv |> to_sorted_list in
|
||||
|
|
@ -270,7 +270,7 @@ eq ~printer:(CCFormat.to_string ppli) [ 0; 3; 4; 6 ]
|
|||
to_sorted_list v)
|
||||
;;
|
||||
|
||||
q Q.small_int (fun size -> create ~size false |> negate |> cardinal = size);;
|
||||
q Q.nat_small (fun size -> create ~size false |> negate |> cardinal = size);;
|
||||
|
||||
t ~name:(spf "line %d" __LINE__) @@ fun () ->
|
||||
let bv1 = CCBV.of_list [ 1; 2; 3; 4 ] in
|
||||
|
|
@ -282,7 +282,7 @@ true
|
|||
;;
|
||||
|
||||
q ~name:"union"
|
||||
Q.(pair (small_list small_nat) (small_list small_nat))
|
||||
Q.(pair (list_small nat_small) (list_small nat_small))
|
||||
(fun (l1, l2) ->
|
||||
let bv1 = of_list l1 in
|
||||
let bv2 = of_list l2 in
|
||||
|
|
@ -343,7 +343,7 @@ true
|
|||
;;
|
||||
|
||||
q ~name:"inter" ~count:10_000
|
||||
Q.(pair (small_list small_nat) (small_list small_nat))
|
||||
Q.(pair (list_small nat_small) (list_small nat_small))
|
||||
(fun (l1, l2) ->
|
||||
let bv1 = of_list l1 in
|
||||
let bv2 = of_list l2 in
|
||||
|
|
@ -374,7 +374,7 @@ diff (of_list [ 1; 2; 3 ]) (of_list [ 1; 2; 3 ]) |> to_list = []
|
|||
;;
|
||||
|
||||
q ~name:"diff" ~count:10_000
|
||||
Q.(pair (small_list small_nat) (small_list small_nat))
|
||||
Q.(pair (list_small nat_small) (list_small nat_small))
|
||||
(fun (l1, l2) ->
|
||||
let bv1 = of_list l1 in
|
||||
let bv2 = of_list l2 in
|
||||
|
|
@ -438,7 +438,7 @@ eq
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(small_int)
|
||||
Q.(nat_small)
|
||||
(fun i ->
|
||||
let i = max 1 i in
|
||||
let bv = create ~size:i true in
|
||||
|
|
@ -526,7 +526,7 @@ t ~name:(spf "line %d" __LINE__) (fun () ->
|
|||
;;
|
||||
|
||||
q ~name:(spf "line %d" __LINE__)
|
||||
Q.(small_list small_nat)
|
||||
Q.(list_small nat_small)
|
||||
(fun l ->
|
||||
let l = CCList.sort_uniq ~cmp:CCInt.compare l in
|
||||
let max = 1 + List.fold_left max 0 l in
|
||||
|
|
@ -636,7 +636,7 @@ module Op = struct
|
|||
|> CCList.keep_some
|
||||
in
|
||||
|
||||
frequency
|
||||
oneof_weighted
|
||||
@@ List.flatten
|
||||
[
|
||||
(if size > 0 then
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ true
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(list small_nat)
|
||||
Q.(list nat_small)
|
||||
(fun l ->
|
||||
let f x = x mod 2 = 0 in
|
||||
let q = of_list l in
|
||||
|
|
@ -284,7 +284,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(list small_nat)
|
||||
Q.(list nat_small)
|
||||
(fun l ->
|
||||
let f x = x mod 2 = 0 in
|
||||
let q = filter f (of_list l) in
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ open CCFun_vec
|
|||
let spf = Printf.sprintf
|
||||
|
||||
let _listuniq =
|
||||
let g = Q.(small_list (pair small_int small_int)) in
|
||||
let g = Q.(list_small (pair nat_small nat_small)) in
|
||||
Q.map_same_type
|
||||
(fun l ->
|
||||
CCList.sort_uniq ~cmp:(fun a b -> Stdlib.compare (fst a) (fst b)) l)
|
||||
|
|
@ -33,7 +33,7 @@ true
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair int (small_list int))
|
||||
Q.(pair int (list_small int))
|
||||
(fun (x, l) ->
|
||||
let q0 = of_list l in
|
||||
let q = push x q0 in
|
||||
|
|
@ -45,18 +45,18 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair (fun1 Observable.int bool) (small_list int))
|
||||
Q.(pair (fun1 Observable.int bool) (list_small int))
|
||||
(fun (f, l) ->
|
||||
let f = Q.Fn.apply f in
|
||||
List.map f l = (of_list l |> map f |> to_list))
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair (small_list int) (small_list int))
|
||||
Q.(pair (list_small int) (list_small int))
|
||||
(fun (l1, l2) -> l1 @ l2 = (append (of_list l1) (of_list l2) |> to_list))
|
||||
;;
|
||||
|
||||
q Q.(small_list int) (fun l -> l = to_list (of_list l));;
|
||||
q Q.(list_small int) (fun l -> l = to_list (of_list l));;
|
||||
|
||||
q _listuniq (fun l ->
|
||||
List.sort Stdlib.compare l
|
||||
|
|
@ -162,7 +162,7 @@ module Op = struct
|
|||
return []
|
||||
else (
|
||||
let op =
|
||||
frequency
|
||||
oneof_weighted
|
||||
@@ List.flatten
|
||||
[
|
||||
[
|
||||
|
|
@ -181,7 +181,7 @@ module Op = struct
|
|||
[]);
|
||||
[
|
||||
( 1,
|
||||
small_list gen_x >|= fun l ->
|
||||
list_small gen_x >|= fun l ->
|
||||
Add_list l, size + List.length l );
|
||||
];
|
||||
]
|
||||
|
|
@ -199,7 +199,7 @@ let arb_ops_int : int Op.t list Q.arbitrary =
|
|||
~print:(fun o ->
|
||||
spf "[%s]" @@ String.concat ";" @@ List.map (Op.show @@ spf "%d") o)
|
||||
~shrink:(Op.shrink_l Q.Shrink.int)
|
||||
Q.Gen.(0 -- 40 >>= fun len -> Op.gen small_int len)
|
||||
Q.Gen.(0 -- 40 >>= fun len -> Op.gen nat_small len)
|
||||
|
||||
let check_ops ~show_x (ops : 'a Op.t list) : unit =
|
||||
let fail () =
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ open CCHashTrie
|
|||
module M = Make (CCInt)
|
||||
|
||||
let _listuniq =
|
||||
let g = Q.(list (pair small_int small_int)) in
|
||||
let g = Q.(list (pair nat_small nat_small)) in
|
||||
Q.map_same_type
|
||||
(fun l ->
|
||||
CCList.sort_uniq ~cmp:(fun a b -> Stdlib.compare (fst a) (fst b)) l)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ let _list_uniq l =
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(small_list (pair int int))
|
||||
Q.(list_small (pair int int))
|
||||
(fun l ->
|
||||
let m = of_list l in
|
||||
is_empty m = (cardinal m = 0))
|
||||
|
|
@ -183,14 +183,14 @@ let inter_l l1 l2 =
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair (small_list (pair small_int unit)) (small_list (pair small_int unit)))
|
||||
Q.(pair (list_small (pair nat_small unit)) (list_small (pair nat_small unit)))
|
||||
(fun (l1, l2) ->
|
||||
union_l l1 l2
|
||||
= _list_uniq @@ to_list (union (fun _ _ _ -> ()) (of_list l1) (of_list l2)))
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair (small_list (pair small_int unit)) (small_list (pair small_int unit)))
|
||||
Q.(pair (list_small (pair nat_small unit)) (list_small (pair nat_small unit)))
|
||||
(fun (l1, l2) ->
|
||||
inter_l l1 l2
|
||||
= _list_uniq @@ to_list (inter (fun _ _ _ -> ()) (of_list l1) (of_list l2)))
|
||||
|
|
@ -225,7 +225,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair (fun2 Observable.int Observable.int bool) (small_list (pair int int)))
|
||||
Q.(pair (fun2 Observable.int Observable.int bool) (list_small (pair int int)))
|
||||
(fun (f, l) ->
|
||||
let (QCheck.Fun (_, f)) = f in
|
||||
_list_uniq (List.filter (fun (x, y) -> f x y) l)
|
||||
|
|
@ -236,7 +236,7 @@ q
|
|||
Q.(
|
||||
pair
|
||||
(fun2 Observable.int Observable.int @@ option bool)
|
||||
(small_list (pair int int)))
|
||||
(list_small (pair int int)))
|
||||
(fun (f, l) ->
|
||||
let (QCheck.Fun (_, f)) = f in
|
||||
_list_uniq
|
||||
|
|
@ -257,7 +257,7 @@ let merge_inter _x o =
|
|||
|
||||
q
|
||||
Q.(
|
||||
let p = small_list (pair small_int small_int) in
|
||||
let p = list_small (pair nat_small nat_small) in
|
||||
pair p p)
|
||||
(fun (l1, l2) ->
|
||||
check_invariants (merge ~f:merge_union (of_list l1) (of_list l2)))
|
||||
|
|
@ -265,7 +265,7 @@ q
|
|||
|
||||
q
|
||||
Q.(
|
||||
let p = small_list (pair small_int small_int) in
|
||||
let p = list_small (pair nat_small nat_small) in
|
||||
pair p p)
|
||||
(fun (l1, l2) ->
|
||||
check_invariants (merge ~f:merge_inter (of_list l1) (of_list l2)))
|
||||
|
|
@ -273,7 +273,7 @@ q
|
|||
|
||||
q
|
||||
Q.(
|
||||
let p = small_list (pair small_int unit) in
|
||||
let p = list_small (pair nat_small unit) in
|
||||
pair p p)
|
||||
(fun (l1, l2) ->
|
||||
let l1 = _list_uniq l1 and l2 = _list_uniq l2 in
|
||||
|
|
@ -284,7 +284,7 @@ q
|
|||
|
||||
q
|
||||
Q.(
|
||||
let p = small_list (pair small_int unit) in
|
||||
let p = list_small (pair nat_small unit) in
|
||||
pair p p)
|
||||
(fun (l1, l2) ->
|
||||
let l1 = _list_uniq l1 and l2 = _list_uniq l2 in
|
||||
|
|
@ -312,7 +312,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(list (pair small_int int))
|
||||
Q.(list (pair nat_small int))
|
||||
(fun l ->
|
||||
of_list l |> cardinal
|
||||
= List.length (l |> List.map fst |> CCList.sort_uniq ~cmp:CCInt.compare))
|
||||
|
|
@ -419,7 +419,7 @@ let tree_gen int_gen : instr_tree Q.Gen.t =
|
|||
Gen.map2 (fun i j -> Singleton (i, j)) int_gen int_gen;
|
||||
]
|
||||
| _ ->
|
||||
frequency
|
||||
oneof_weighted
|
||||
[
|
||||
1, return Empty;
|
||||
1, map2 (fun k v -> Singleton (k, v)) int_gen int_gen;
|
||||
|
|
@ -469,7 +469,7 @@ let rec tshrink t : instr_tree Q.Iter.t =
|
|||
<+> Iter.map (fun t1' -> Inter (t0, t1')) (tshrink t1)
|
||||
|
||||
let arb_int =
|
||||
frequency [ 5, small_signed_int; 3, int; 1, oneofl [ min_int; max_int ] ]
|
||||
oneof_weighted [ 5, int_small; 3, int; 1, oneof_list [ min_int; max_int ] ]
|
||||
|
||||
let arb_tree = make ~print:to_string ~shrink:tshrink (tree_gen arb_int.gen)
|
||||
let empty_m = []
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ let _list_uniq =
|
|||
let _list_int_int =
|
||||
Q.(
|
||||
map_same_type _list_uniq
|
||||
(list_of_size Gen.(0 -- 40) (pair small_int small_int)))
|
||||
(list_size Gen.(0 -- 40) (pair nat_small nat_small)))
|
||||
;;
|
||||
|
||||
t @@ fun () ->
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ open Test
|
|||
open CCRAL;;
|
||||
|
||||
q
|
||||
Q.(pair (pair small_int int) (list int))
|
||||
Q.(pair (pair nat_small int) (list int))
|
||||
(fun ((i, v), l) ->
|
||||
l = []
|
||||
||
|
||||
|
|
@ -14,7 +14,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(list small_int)
|
||||
Q.(list nat_small)
|
||||
(fun l ->
|
||||
let l1 = of_list l in
|
||||
CCList.mapi (fun i x -> i, x) l
|
||||
|
|
@ -32,7 +32,7 @@ tl l |> to_list = [ 2; 3 ]
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(list_of_size Gen.(1 -- 100) int)
|
||||
Q.(list_size Gen.(1 -- 100) int)
|
||||
(fun l ->
|
||||
let open Q in
|
||||
let l' = of_list l in
|
||||
|
|
@ -51,14 +51,14 @@ eq
|
|||
(CCPair.map_snd to_list @@ get_and_remove_exn (of_list [ 1; 2; 3; 4 ]) 2)
|
||||
;;
|
||||
|
||||
q Q.small_int (fun n ->
|
||||
q Q.nat_small (fun n ->
|
||||
let l = CCList.(0 -- n) in
|
||||
let l' = of_list l |> mapi ~f:(fun i x -> i, x) in
|
||||
List.mapi (fun i x -> i, x) l = to_list l')
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair (list small_int) (fun2 Observable.int Observable.int bool))
|
||||
Q.(pair (list nat_small) (fun2 Observable.int Observable.int bool))
|
||||
(fun (l, f) ->
|
||||
let f = Q.Fn.apply f in
|
||||
mapi ~f (of_list l) |> to_list = List.mapi f l)
|
||||
|
|
@ -72,14 +72,14 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(list small_int)
|
||||
Q.(list nat_small)
|
||||
(fun l ->
|
||||
let l = of_list l in
|
||||
rev (rev l) = l)
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(list small_int)
|
||||
Q.(list nat_small)
|
||||
(fun l ->
|
||||
let l1 = of_list l in
|
||||
length l1 = List.length l)
|
||||
|
|
@ -97,7 +97,7 @@ of_list [ 1; 2; 3; 4; 5; 6 ]
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair (fun1 Observable.int (small_list int)) (small_list int))
|
||||
Q.(pair (fun1 Observable.int (list_small int)) (list_small int))
|
||||
(fun (f, l) ->
|
||||
let f x = Q.Fn.apply f x in
|
||||
let f' x = f x |> of_list in
|
||||
|
|
@ -110,7 +110,7 @@ flatten (of_list [ of_list [ 1 ]; of_list []; of_list [ 2; 3 ] ])
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(small_list (small_list int))
|
||||
Q.(list_small (list_small int))
|
||||
(fun l ->
|
||||
of_list l |> map ~f:of_list |> flatten |> to_list = CCList.flatten l)
|
||||
;;
|
||||
|
|
@ -126,7 +126,7 @@ t @@ fun () -> take 5 (of_list CCList.(1 -- 10)) |> to_list = [ 1; 2; 3; 4; 5 ]
|
|||
t @@ fun () -> take 0 (of_list CCList.(1 -- 10)) |> to_list = [];;
|
||||
|
||||
q
|
||||
Q.(pair small_int (list int))
|
||||
Q.(pair nat_small (list int))
|
||||
(fun (n, l) -> of_list l |> take n |> to_list = CCList.take n l)
|
||||
;;
|
||||
|
||||
|
|
@ -147,7 +147,7 @@ q
|
|||
t @@ fun () -> of_list [ 1; 2; 3 ] |> drop 2 |> length = 1;;
|
||||
|
||||
q
|
||||
Q.(pair small_int (list int))
|
||||
Q.(pair nat_small (list int))
|
||||
(fun (n, l) -> of_list l |> drop n |> to_list = CCList.drop n l)
|
||||
;;
|
||||
|
||||
|
|
@ -158,7 +158,7 @@ t @@ fun () -> drop 0 (of_list CCList.(1 -- 10)) |> to_list = CCList.(1 -- 10);;
|
|||
t @@ fun () -> drop 15 (of_list CCList.(1 -- 10)) |> to_list = [];;
|
||||
|
||||
q
|
||||
Q.(list_of_size Gen.(0 -- 200) int)
|
||||
Q.(list_size Gen.(0 -- 200) int)
|
||||
(fun l ->
|
||||
let f x = x mod 10 <> 0 in
|
||||
of_list l |> drop_while ~f |> to_list = CCList.drop_while f l)
|
||||
|
|
@ -170,7 +170,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair small_int (small_list int))
|
||||
Q.(pair nat_small (list_small int))
|
||||
(fun (n, l) -> of_list l |> repeat n |> to_list = CCList.(repeat n l))
|
||||
;;
|
||||
|
||||
|
|
@ -179,7 +179,7 @@ t @@ fun () -> range 3 0 |> to_list = [ 3; 2; 1; 0 ];;
|
|||
t @@ fun () -> range 17 17 |> to_list = [ 17 ];;
|
||||
|
||||
q
|
||||
Q.(pair small_int small_int)
|
||||
Q.(pair nat_small nat_small)
|
||||
(fun (i, j) -> range i j |> to_list = CCList.(i -- j))
|
||||
|
||||
let eq' = eq ~printer:CCFormat.(to_string (hbox (list int)));;
|
||||
|
|
@ -190,21 +190,21 @@ eq' [ 1 ] (1 --^ 2 |> to_list);;
|
|||
eq' [] (0 --^ 0 |> to_list);;
|
||||
|
||||
q
|
||||
Q.(pair (list small_int) (list small_int))
|
||||
Q.(pair (list nat_small) (list nat_small))
|
||||
(fun (l1, l2) -> add_list (of_list l2) l1 |> to_list = l1 @ l2)
|
||||
;;
|
||||
|
||||
q Q.(list int) (fun l -> to_list (of_list l) = l);;
|
||||
q Q.(array int) (fun a -> of_array a |> to_array = a);;
|
||||
q Q.(list small_int) (fun l -> of_list l |> to_iter |> Iter.to_list = l);;
|
||||
q Q.(list small_int) (fun l -> Iter.of_list l |> of_iter |> to_list = l);;
|
||||
q Q.(list nat_small) (fun l -> of_list l |> to_iter |> Iter.to_list = l);;
|
||||
q Q.(list nat_small) (fun l -> Iter.of_list l |> of_iter |> to_list = l);;
|
||||
|
||||
t @@ fun () ->
|
||||
add_iter (of_list [ 3; 4 ]) (Iter.of_list [ 1; 2 ]) |> to_list = [ 1; 2; 3; 4 ]
|
||||
;;
|
||||
|
||||
q Q.(list small_int) (fun l -> of_list l |> to_gen |> Gen.to_list = l);;
|
||||
q Q.(list small_int) (fun l -> Gen.of_list l |> of_gen |> to_list = l);;
|
||||
q Q.(list nat_small) (fun l -> of_list l |> to_gen |> Gen.to_list = l);;
|
||||
q Q.(list nat_small) (fun l -> Gen.of_list l |> of_gen |> to_list = l);;
|
||||
|
||||
q
|
||||
Q.(pair (list int) (list int))
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ q a_str (fun s ->
|
|||
with Exit -> false)
|
||||
;;
|
||||
|
||||
q (Q.pair Q.small_int a_str) (fun (i, s) ->
|
||||
q (Q.pair Q.nat_small a_str) (fun (i, s) ->
|
||||
let s = Bytes.of_string (s ^ " ") in
|
||||
let s_len = Bytes.length s in
|
||||
let b = Byte.create (max s_len 64) in
|
||||
|
|
@ -168,7 +168,7 @@ q (Q.pair Q.small_int a_str) (fun (i, s) ->
|
|||
front = Bytes.get s index)
|
||||
;;
|
||||
|
||||
q (Q.pair Q.small_int a_str) (fun (i, s) ->
|
||||
q (Q.pair Q.nat_small a_str) (fun (i, s) ->
|
||||
let s = Bytes.of_string (s ^ " ") in
|
||||
let s_len = Bytes.length s in
|
||||
let b = Byte.create (max s_len 64) in
|
||||
|
|
@ -370,7 +370,7 @@ let gen_op =
|
|||
assert (len >= 0 && len <= String.length s);
|
||||
0 -- (String.length s - len) >|= fun i -> blit s i len
|
||||
in
|
||||
frequency
|
||||
oneof_weighted
|
||||
[
|
||||
3, return Take_back;
|
||||
3, return Take_front;
|
||||
|
|
@ -385,7 +385,7 @@ let gen_op =
|
|||
]
|
||||
|
||||
let arb_op = Q.make ~shrink:shrink_op ~print:str_of_op gen_op
|
||||
let arb_ops = Q.list_of_size Q.Gen.(0 -- 20) arb_op
|
||||
let arb_ops = Q.list_size Q.Gen.(0 -- 20) arb_op
|
||||
|
||||
module L_impl = struct
|
||||
type t = {
|
||||
|
|
|
|||
|
|
@ -3,45 +3,45 @@ open Test
|
|||
open CCSimple_queue;;
|
||||
|
||||
q
|
||||
Q.(list small_int)
|
||||
Q.(list nat_small)
|
||||
(fun l ->
|
||||
let q = of_list l in
|
||||
equal CCInt.equal (Gen.unfold pop q |> of_gen) q)
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(list small_int)
|
||||
Q.(list nat_small)
|
||||
(fun l -> equal CCInt.equal (of_list l |> rev) (of_list (List.rev l)))
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(list small_int)
|
||||
Q.(list nat_small)
|
||||
(fun l ->
|
||||
let q = of_list l in
|
||||
equal CCInt.equal q (q |> rev |> rev))
|
||||
;;
|
||||
|
||||
q Q.(list small_int) (fun l -> length (of_list l) = List.length l);;
|
||||
q Q.(list nat_small) (fun l -> length (of_list l) = List.length l);;
|
||||
|
||||
q
|
||||
Q.(list small_int)
|
||||
Q.(list nat_small)
|
||||
(fun l -> equal CCInt.equal (of_list l) (List.fold_left snoc empty l))
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(list small_int)
|
||||
Q.(list nat_small)
|
||||
(fun l -> equal CCInt.equal (of_iter (Iter.of_list l)) (of_list l))
|
||||
;;
|
||||
|
||||
q Q.(list small_int) (fun l -> l = (of_list l |> to_iter |> Iter.to_list));;
|
||||
q Q.(list nat_small) (fun l -> l = (of_list l |> to_iter |> Iter.to_list));;
|
||||
|
||||
q
|
||||
Q.(pair (list small_int) (list small_int))
|
||||
Q.(pair (list nat_small) (list nat_small))
|
||||
(fun (l1, l2) -> equal CCInt.equal (of_list l1) (of_list l2) = (l1 = l2))
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair (list small_int) (list small_int))
|
||||
Q.(pair (list nat_small) (list nat_small))
|
||||
(fun (l1, l2) ->
|
||||
equal CCInt.equal
|
||||
(append (of_list l1) (of_list l2))
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ eq ~printer:CCFun.id "catogan" (String.longest_prefix "catogan" s1);;
|
|||
q
|
||||
Q.(
|
||||
pair
|
||||
(list (pair (printable_string_of_size Gen.(0 -- 30)) int))
|
||||
printable_string)
|
||||
(list (pair (string_size_of Gen.(0 -- 30) Gen.char_printable) int))
|
||||
string_printable)
|
||||
(fun (l, s) ->
|
||||
let m = String.of_list l in
|
||||
let s' = String.longest_prefix s m in
|
||||
|
|
@ -61,7 +61,7 @@ eq
|
|||
|
||||
q ~count:30
|
||||
Q.(
|
||||
let p = list_of_size Gen.(0 -- 100) (pair printable_string small_int) in
|
||||
let p = list_size Gen.(0 -- 100) (pair string_printable nat_small) in
|
||||
pair p p)
|
||||
(fun (l1, l2) ->
|
||||
let t1 = S.of_list l1 and t2 = S.of_list l2 in
|
||||
|
|
@ -109,7 +109,7 @@ true
|
|||
;;
|
||||
|
||||
q ~count:30
|
||||
Q.(list_of_size Gen.(0 -- 100) (pair printable_string small_int))
|
||||
Q.(list_size Gen.(0 -- 100) (pair string_printable nat_small))
|
||||
(fun l ->
|
||||
let t = S.of_list l in
|
||||
S.check_invariants t)
|
||||
|
|
@ -123,10 +123,10 @@ let rec sorted ~rev = function
|
|||
x <= y)
|
||||
&& sorted ~rev tl
|
||||
|
||||
let gen_str = Q.small_printable_string;;
|
||||
let gen_str = Q.(string_size_of Gen.nat_small Gen.char_printable);;
|
||||
|
||||
q ~count:200
|
||||
Q.(list_of_size Gen.(1 -- 20) (pair gen_str small_int))
|
||||
Q.(list_size Gen.(1 -- 20) (pair gen_str nat_small))
|
||||
(fun l ->
|
||||
let t = String.of_list l in
|
||||
List.for_all
|
||||
|
|
@ -135,7 +135,7 @@ q ~count:200
|
|||
;;
|
||||
|
||||
q ~count:200
|
||||
Q.(list_of_size Gen.(1 -- 20) (pair gen_str small_int))
|
||||
Q.(list_size Gen.(1 -- 20) (pair gen_str nat_small))
|
||||
(fun l ->
|
||||
let t = String.of_list l in
|
||||
List.for_all
|
||||
|
|
@ -144,7 +144,7 @@ q ~count:200
|
|||
;;
|
||||
|
||||
q ~count:200
|
||||
Q.(list_of_size Gen.(1 -- 20) (pair gen_str small_int))
|
||||
Q.(list_size Gen.(1 -- 20) (pair gen_str nat_small))
|
||||
(fun l ->
|
||||
let t = String.of_list l in
|
||||
List.for_all
|
||||
|
|
@ -153,7 +153,7 @@ q ~count:200
|
|||
;;
|
||||
|
||||
q ~count:200
|
||||
Q.(list_of_size Gen.(1 -- 20) (pair gen_str small_int))
|
||||
Q.(list_size Gen.(1 -- 20) (pair gen_str nat_small))
|
||||
(fun l ->
|
||||
let t = String.of_list l in
|
||||
List.for_all
|
||||
|
|
|
|||
|
|
@ -48,14 +48,14 @@ q ~count:200
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(list (pair small_int bool))
|
||||
Q.(list (pair nat_small bool))
|
||||
(fun l ->
|
||||
let m = M.of_list l in
|
||||
M.balanced m)
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(list (pair small_int small_int))
|
||||
Q.(list (pair nat_small nat_small))
|
||||
(fun l ->
|
||||
let l = _list_uniq l in
|
||||
let m = M.of_list l in
|
||||
|
|
@ -63,7 +63,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(list (pair small_int small_int))
|
||||
Q.(list (pair nat_small nat_small))
|
||||
(fun l ->
|
||||
let l = _list_uniq l in
|
||||
let m = M.of_list l in
|
||||
|
|
@ -71,7 +71,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(list_of_size Gen.(0 -- 30) (pair small_int small_int))
|
||||
Q.(list_size Gen.(0 -- 30) (pair nat_small nat_small))
|
||||
(fun l ->
|
||||
let m = M.of_list l in
|
||||
List.for_all
|
||||
|
|
@ -84,7 +84,7 @@ q
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(list_of_size Gen.(0 -- 30) (pair small_int small_int))
|
||||
Q.(list_size Gen.(0 -- 30) (pair nat_small nat_small))
|
||||
(fun l ->
|
||||
let m = M.of_list l in
|
||||
List.for_all
|
||||
|
|
@ -100,7 +100,7 @@ List.for_all (fun i -> M.nth_exn i m = (i, i)) CCList.(0 -- 1000)
|
|||
;;
|
||||
|
||||
q ~count:1_000
|
||||
Q.(list_of_size Gen.(0 -- 30) (pair small_int small_int))
|
||||
Q.(list_size Gen.(0 -- 30) (pair nat_small nat_small))
|
||||
(fun l ->
|
||||
let l = CCList.sort_uniq ~cmp:(CCFun.compose_binop fst compare) l in
|
||||
let m = M.of_list l in
|
||||
|
|
@ -113,7 +113,7 @@ q ~count:1_000
|
|||
;;
|
||||
|
||||
q ~count:20
|
||||
Q.(list_of_size Gen.(1 -- 100) (pair small_int small_int))
|
||||
Q.(list_size Gen.(1 -- 100) (pair nat_small nat_small))
|
||||
(fun lst ->
|
||||
let lst = _list_uniq lst in
|
||||
let m = M.of_list lst in
|
||||
|
|
@ -143,7 +143,7 @@ true
|
|||
|
||||
q
|
||||
Q.(
|
||||
let p = list (pair small_int small_int) in
|
||||
let p = list (pair nat_small nat_small) in
|
||||
pair p p)
|
||||
(fun (l1, l2) ->
|
||||
let l1 = _list_uniq l1 and l2 = _list_uniq l2 in
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ open CCZipper;;
|
|||
t @@ fun () -> is_empty empty;;
|
||||
t @@ fun () -> not ([ 42 ] |> make |> right |> is_empty)
|
||||
|
||||
let zip_gen = Q.(pair (small_list int) (small_list int));;
|
||||
let zip_gen = Q.(pair (list_small int) (list_small int));;
|
||||
|
||||
q zip_gen (fun z -> to_list z = List.rev (to_rev_list z));;
|
||||
q zip_gen (fun g -> is_focused g = (focused g |> CCOption.is_some));;
|
||||
|
||||
q
|
||||
Q.(triple int (list small_int) (list small_int))
|
||||
Q.(triple int (list nat_small) (list nat_small))
|
||||
(fun (x, l, r) -> insert x (l, r) |> remove = (l, r))
|
||||
;;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ open Containers_pvec
|
|||
let spf = Printf.sprintf
|
||||
|
||||
let _listuniq =
|
||||
let g = Q.(small_list (pair small_int small_int)) in
|
||||
let g = Q.(list_small (pair nat_small nat_small)) in
|
||||
Q.map_same_type
|
||||
(fun l ->
|
||||
CCList.sort_uniq ~cmp:(fun a b -> Stdlib.compare (fst a) (fst b)) l)
|
||||
|
|
@ -33,7 +33,7 @@ true
|
|||
;;
|
||||
|
||||
q ~name:"push length pop"
|
||||
Q.(pair int (small_list int))
|
||||
Q.(pair int (list_small int))
|
||||
(fun (x, l) ->
|
||||
let q0 = of_list l in
|
||||
let q = push q0 x in
|
||||
|
|
@ -45,18 +45,18 @@ q ~name:"push length pop"
|
|||
;;
|
||||
|
||||
q
|
||||
Q.(pair (fun1 Observable.int bool) (small_list int))
|
||||
Q.(pair (fun1 Observable.int bool) (list_small int))
|
||||
(fun (f, l) ->
|
||||
let f = Q.Fn.apply f in
|
||||
List.map f l = (of_list l |> map f |> to_list))
|
||||
;;
|
||||
|
||||
q
|
||||
Q.(pair (small_list int) (small_list int))
|
||||
Q.(pair (list_small int) (list_small int))
|
||||
(fun (l1, l2) -> l1 @ l2 = (append (of_list l1) (of_list l2) |> to_list))
|
||||
;;
|
||||
|
||||
q Q.(small_list int) (fun l -> l = to_list (of_list l));;
|
||||
q Q.(list_small int) (fun l -> l = to_list (of_list l));;
|
||||
|
||||
q _listuniq (fun l ->
|
||||
List.sort Stdlib.compare l
|
||||
|
|
@ -74,11 +74,11 @@ t @@ fun () -> choose empty = None;;
|
|||
t @@ fun () -> choose (of_list [ 1, 1; 2, 2 ]) <> None;;
|
||||
|
||||
q
|
||||
Q.(pair (small_list int) (small_list int))
|
||||
Q.(pair (list_small int) (list_small int))
|
||||
(fun (l1, l2) -> equal CCInt.equal (of_list l1) (of_list l2) = (l1 = l2))
|
||||
;;
|
||||
|
||||
q Q.(small_list int) (fun l1 -> equal CCInt.equal (of_list l1) (of_list l1))
|
||||
q Q.(list_small int) (fun l1 -> equal CCInt.equal (of_list l1) (of_list l1))
|
||||
|
||||
let arb_list_with_idx =
|
||||
let open Q in
|
||||
|
|
@ -87,7 +87,7 @@ let arb_list_with_idx =
|
|||
in
|
||||
let gen =
|
||||
Gen.(
|
||||
let* l = small_list int in
|
||||
let* l = list_small int in
|
||||
let+ i =
|
||||
if l = [] then
|
||||
return 0
|
||||
|
|
@ -238,7 +238,7 @@ module Op = struct
|
|||
return []
|
||||
else (
|
||||
let op =
|
||||
frequency
|
||||
oneof_weighted
|
||||
@@ List.flatten
|
||||
[
|
||||
[
|
||||
|
|
@ -260,10 +260,10 @@ module Op = struct
|
|||
[]);
|
||||
[
|
||||
( 1,
|
||||
small_list gen_x >|= fun l ->
|
||||
list_small gen_x >|= fun l ->
|
||||
Add_list l, size + List.length l );
|
||||
( 1,
|
||||
small_list gen_x >|= fun l ->
|
||||
list_small gen_x >|= fun l ->
|
||||
Append l, size + List.length l );
|
||||
( 1,
|
||||
list_size (0 -- 5) gen_x >|= fun l ->
|
||||
|
|
@ -284,7 +284,7 @@ let arb_ops_int : int Op.t list Q.arbitrary =
|
|||
~print:(fun o ->
|
||||
spf "[%s]" @@ String.concat ";" @@ List.map (Op.show @@ spf "%d") o)
|
||||
~shrink:(Op.shrink_l Q.Shrink.int)
|
||||
Q.Gen.(0 -- 40 >>= fun len -> Op.gen small_int len)
|
||||
Q.Gen.(0 -- 40 >>= fun len -> Op.gen nat_small len)
|
||||
|
||||
let check_ops ~show_x (ops : 'a Op.t list) : unit =
|
||||
let fail () =
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue