update headers; reindent

This commit is contained in:
Simon Cruanes 2017-07-04 13:13:07 +02:00
parent 296cdc8748
commit aab19f6a50
16 changed files with 98 additions and 142 deletions

View file

@ -73,10 +73,10 @@ val sort_indices : ('a -> 'a -> int) -> 'a t -> int array
(** [sort_indices cmp a] returns a new array [b], with the same length as [a], (** [sort_indices cmp a] returns a new array [b], with the same length as [a],
such that [b.(i)] is the index at which the [i]-th element of [sorted cmp a] such that [b.(i)] is the index at which the [i]-th element of [sorted cmp a]
appears in [a]. [a] is not modified. appears in [a]. [a] is not modified.
In other words, [map (fun i -> a.(i)) (sort_indices cmp a) = sorted cmp a]. In other words, [map (fun i -> a.(i)) (sort_indices cmp a) = sorted cmp a].
[sort_indices] yields the inverse permutation of {!sort_ranking}. [sort_indices] yields the inverse permutation of {!sort_ranking}.
@since 1.0 *) @since 1.0 *)
val sort_ranking : ('a -> 'a -> int) -> 'a t -> int array val sort_ranking : ('a -> 'a -> int) -> 'a t -> int array

View file

@ -88,20 +88,20 @@ val sort_indices : ('a -> 'a -> int) -> 'a t -> int array
(** [sort_indices cmp a] returns a new array [b], with the same length as [a], (** [sort_indices cmp a] returns a new array [b], with the same length as [a],
such that [b.(i)] is the index at which the [i]-th element of [sorted cmp a] such that [b.(i)] is the index at which the [i]-th element of [sorted cmp a]
appears in [a]. [a] is not modified. appears in [a]. [a] is not modified.
In other words, [map (fun i -> a.(i)) (sort_indices cmp a) = sorted cmp a]. In other words, [map (fun i -> a.(i)) (sort_indices cmp a) = sorted cmp a].
[sort_indices] yields the inverse permutation of {!sort_ranking}. [sort_indices] yields the inverse permutation of {!sort_ranking}.
@since 1.0 *) @since 1.0 *)
val sort_ranking : ('a -> 'a -> int) -> 'a t -> int array val sort_ranking : ('a -> 'a -> int) -> 'a t -> int array
(** [sort_ranking cmp a] returns a new array [b], with the same length as [a], (** [sort_ranking cmp a] returns a new array [b], with the same length as [a],
such that [b.(i)] is the index at which the [i]-the element of [a] appears such that [b.(i)] is the index at which the [i]-the element of [a] appears
in [sorted cmp a]. [a] is not modified. in [sorted cmp a]. [a] is not modified.
In other words, [map (fun i -> (sorted cmp a).(i)) (sort_ranking cmp a) = a]. In other words, [map (fun i -> (sorted cmp a).(i)) (sort_ranking cmp a) = a].
[sort_ranking] yields the inverse permutation of {!sort_indices}. [sort_ranking] yields the inverse permutation of {!sort_indices}.
In the absence of duplicate elements in [a], we also have In the absence of duplicate elements in [a], we also have
[lookup_exn a.(i) (sorted a) = (sorted_ranking a).(i)] [lookup_exn a.(i) (sorted a) = (sorted_ranking a).(i)]
@since 1.0 *) @since 1.0 *)

View file

@ -77,7 +77,7 @@ let text out (s:string): unit =
(*$= & ~printer:(fun s->CCFormat.sprintf "%S" s) (*$= & ~printer:(fun s->CCFormat.sprintf "%S" s)
"a\nb\nc" (sprintf_no_color "@[<v>%a@]%!" text "a b c") "a\nb\nc" (sprintf_no_color "@[<v>%a@]%!" text "a b c")
"a b\nc" (sprintf_no_color "@[<h>%a@]%!" text "a b\nc") "a b\nc" (sprintf_no_color "@[<h>%a@]%!" text "a b\nc")
*) *)
let list ?(sep=return ",@ ") pp fmt l = let list ?(sep=return ",@ ") pp fmt l =
let rec pp_list l = match l with let rec pp_list l = match l with

View file

@ -366,7 +366,7 @@ let combine l1 l2 =
if List.length l1=List.length l2 \ if List.length l1=List.length l2 \
then CCList.combine l1 l2 = List.combine l1 l2 \ then CCList.combine l1 l2 = List.combine l1 l2 \
else Q.assume_fail() ) else Q.assume_fail() )
*) *)
let combine_gen l1 l2 = let combine_gen l1 l2 =
let l1 = ref l1 in let l1 = ref l1 in
@ -385,7 +385,7 @@ let combine_gen l1 l2 =
let res1 = combine (take n l1) (take n l2) in \ let res1 = combine (take n l1) (take n l2) in \
let res2 = combine_gen l1 l2 |> of_gen in \ let res2 = combine_gen l1 l2 |> of_gen in \
res1 = res2) res1 = res2)
*) *)
let split l = let split l =
let rec direct i l = match l with let rec direct i l = match l with
@ -396,10 +396,10 @@ let split l =
| [x1, y1; x2, y2; x3, y3; x4, y4] -> [x1;x2;x3;x4], [y1;y2;y3;y4] | [x1, y1; x2, y2; x3, y3; x4, y4] -> [x1;x2;x3;x4], [y1;y2;y3;y4]
| _ when i=0 -> split_slow ([], []) l | _ when i=0 -> split_slow ([], []) l
| (x1, y1) :: | (x1, y1) ::
(x2, y2) :: (x2, y2) ::
(x3, y3) :: (x3, y3) ::
(x4, y4) :: (x4, y4) ::
(x5, y5) :: l' -> (x5, y5) :: l' ->
let rx, ry = direct (i-1) l' in let rx, ry = direct (i-1) l' in
x1 :: x2 :: x3 :: x4 :: x5 :: rx, x1 :: x2 :: x3 :: x4 :: x5 :: rx,
y1 :: y2 :: y3 :: y4 :: y5 :: ry y1 :: y2 :: y3 :: y4 :: y5 :: ry
@ -409,7 +409,7 @@ let split l =
let acc = x1 :: fst acc, y1 :: snd acc in let acc = x1 :: fst acc, y1 :: snd acc in
split_slow acc l' split_slow acc l'
in in
direct direct_depth_default_ l direct direct_depth_default_ l
(*$Q (*$Q
(Q.(list (pair int string))) (fun l -> \ (Q.(list (pair int string))) (fun l -> \

View file

@ -114,13 +114,13 @@ val fold_product : ('c -> 'a -> 'b -> 'c) -> 'c -> 'a t -> 'b t -> 'c
val cartesian_product : 'a t t -> 'a t t val cartesian_product : 'a t t -> 'a t t
(** (**
For example: For example:
{[ {[
# cartesian_product [[1;2];[3];[4;5;6]] = # cartesian_product [[1;2];[3];[4;5;6]] =
[[1;3;4];[1;3;5];[1;3;6];[2;3;4];[2;3;5];[2;3;6]];; [[1;3;4];[1;3;5];[1;3;6];[2;3;4];[2;3;5];[2;3;6]];;
# cartesian_product [[1;2];[];[4;5;6]] = [];; # cartesian_product [[1;2];[];[4;5;6]] = [];;
# cartesian_product [[1;2];[3];[4];[5];[6]] = # cartesian_product [[1;2];[3];[4];[5];[6]] =
[[1;3;4;5;6];[2;3;4;5;6]];; [[1;3;4;5;6];[2;3;4;5;6]];;
]} ]}
invariant: [cartesian_product l = map_product id l]. invariant: [cartesian_product l = map_product id l].
@since 1.2 *) @since 1.2 *)

View file

@ -129,7 +129,7 @@ let fold_ok f acc r = match r with
(*$= (*$=
42 (fold_ok (+) 2 (Ok 40)) 42 (fold_ok (+) 2 (Ok 40))
40 (fold_ok (+) 40 (Error "foo")) 40 (fold_ok (+) 40 (Error "foo"))
*) *)
let is_ok = function let is_ok = function
| Ok _ -> true | Ok _ -> true

View file

@ -375,7 +375,7 @@ val rtrim : t -> t
Q.(printable_string) (fun s -> \ Q.(printable_string) (fun s -> \
let s' = rtrim s in \ let s' = rtrim s in \
if s'="" then Q.assume_fail() else s'.[String.length s'-1] <> ' ') if s'="" then Q.assume_fail() else s'.[String.length s'-1] <> ' ')
*) *)
(** {2 Operations on 2 strings} *) (** {2 Operations on 2 strings} *)
@ -654,7 +654,7 @@ module Sub : sig
(*$= & ~printer:(String.make 1) (*$= & ~printer:(String.make 1)
'b' Sub.(get (make "abc" 1 ~len:2) 0) 'b' Sub.(get (make "abc" 1 ~len:2) 0)
'c' Sub.(get (make "abc" 1 ~len:2) 1) 'c' Sub.(get (make "abc" 1 ~len:2) 1)
*) *)
(*$QR (*$QR
Q.(printable_string_of_size Gen.(3--10)) (fun s -> Q.(printable_string_of_size Gen.(3--10)) (fun s ->

View file

@ -269,7 +269,7 @@ let iter bv f =
let bv = create ~size:n true in \ let bv = create ~size:n true in \
let l = iter bv |> Sequence.zip |> Sequence.to_list in \ let l = iter bv |> Sequence.zip |> Sequence.to_list in \
List.length l = n && List.for_all (fun (_,b) -> b) l) List.length l = n && List.for_all (fun (_,b) -> b) l)
*) *)
let iter_true bv f = let iter_true bv f =
iter bv (fun i b -> if b then f i else ()) iter bv (fun i b -> if b then f i else ())

View file

@ -86,9 +86,9 @@ val first : t -> int option
changed type at 1.2 *) changed type at 1.2 *)
val first_exn : t -> int val first_exn : t -> int
(** First set bit, or (** First set bit, or
@raise Not_found if all bits are 0 @raise Not_found if all bits are 0
@since 1.2 *) @since 1.2 *)
val filter : t -> (int -> bool) -> unit val filter : t -> (int -> bool) -> unit
(** [filter bv p] only keeps the true bits of [bv] whose [index] (** [filter bv p] only keeps the true bits of [bv] whose [index]

View file

@ -1,27 +1,5 @@
(*
Copyright (c) 2013, Simon Cruanes
All rights reserved.
Redistribution and use in source and binary forms, with or without (* This file is free software, part of containers. See file "license" for more details. *)
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer. Redistributions in binary
form must reproduce the above copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other materials provided with
the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*)
(** {1 Caches} *) (** {1 Caches} *)

View file

@ -1,27 +1,5 @@
(*
Copyright (c) 2013, Simon Cruanes
All rights reserved.
Redistribution and use in source and binary forms, with or without (* This file is free software, part of containers. See file "license" for more details. *)
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer. Redistributions in binary
form must reproduce the above copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other materials provided with
the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*)
(** {1 Caches} (** {1 Caches}

View file

@ -300,7 +300,7 @@ module Traverse = struct
`Exit 345614] `Exit 345614]
in in
assert_equal expected l assert_equal expected l
*) *)
end end
(** {2 Cycles} *) (** {2 Cycles} *)

View file

@ -238,13 +238,13 @@ let update k f t =
let doubleton k1 v1 k2 v2 = add k1 v1 (singleton k2 v2) let doubleton k1 v1 k2 v2 = add k1 v1 (singleton k2 v2)
let rec equal ~eq a b = a==b || match a, b with let rec equal ~eq a b = a==b || match a, b with
| E, E -> true | E, E -> true
| L (ka, va), L (kb, vb) -> ka = kb && eq va vb | L (ka, va), L (kb, vb) -> ka = kb && eq va vb
| N (pa, sa, la, ra), N (pb, sb, lb, rb) -> | N (pa, sa, la, ra), N (pb, sb, lb, rb) ->
pa=pb && sa=sb && equal ~eq la lb && equal ~eq ra rb pa=pb && sa=sb && equal ~eq la lb && equal ~eq ra rb
| E, _ | E, _
| N _, _ | N _, _
| L _, _ -> false | L _, _ -> false
(*$Q (*$Q
Q.(list (pair int bool)) ( fun l -> \ Q.(list (pair int bool)) ( fun l -> \
@ -289,23 +289,23 @@ let choose t =
let rec union f t1 t2 = let rec union f t1 t2 =
if t1==t2 then t1 if t1==t2 then t1
else match t1, t2 with else match t1, t2 with
| E, o | o, E -> o | E, o | o, E -> o
| L (k, v), o | L (k, v), o
| o, L (k, v) -> | o, L (k, v) ->
(* insert k, v into o *) (* insert k, v into o *)
insert_ (fun ~old v -> f k old v) k v o insert_ (fun ~old v -> f k old v) k v o
| N (p1, m1, l1, r1), N (p2, m2, l2, r2) -> | N (p1, m1, l1, r1), N (p2, m2, l2, r2) ->
if p1 = p2 && m1 = m2 if p1 = p2 && m1 = m2
then mk_node_ p1 m1 (union f l1 l2) (union f r1 r2) then mk_node_ p1 m1 (union f l1 l2) (union f r1 r2)
else if Bit.gt m1 m2 && is_prefix_ ~prefix:p1 p2 ~bit:m1 else if Bit.gt m1 m2 && is_prefix_ ~prefix:p1 p2 ~bit:m1
then if Bit.is_0 p2 ~bit:m1 then if Bit.is_0 p2 ~bit:m1
then N (p1, m1, union f l1 t2, r1) then N (p1, m1, union f l1 t2, r1)
else N (p1, m1, l1, union f r1 t2) else N (p1, m1, l1, union f r1 t2)
else if Bit.lt m1 m2 && is_prefix_ ~prefix:p2 p1 ~bit:m2 else if Bit.lt m1 m2 && is_prefix_ ~prefix:p2 p1 ~bit:m2
then if Bit.is_0 p1 ~bit:m2 then if Bit.is_0 p1 ~bit:m2
then N (p2, m2, union f t1 l2, r2) then N (p2, m2, union f t1 l2, r2)
else N (p2, m2, l2, union f t1 r2) else N (p2, m2, l2, union f t1 r2)
else join_ t1 p1 t2 p2 else join_ t1 p1 t2 p2
(*$Q & ~small:(fun (a,b) -> List.length a + List.length b) (*$Q & ~small:(fun (a,b) -> List.length a + List.length b)
Q.(pair (list (pair int bool)) (list (pair int bool))) (fun (l1,l2) -> \ Q.(pair (list (pair int bool)) (list (pair int bool))) (fun (l1,l2) -> \
@ -344,26 +344,26 @@ let rec union f t1 t2 =
let rec inter f a b = let rec inter f a b =
if a==b then a if a==b then a
else match a, b with else match a, b with
| E, _ | _, E -> E | E, _ | _, E -> E
| L (k, v), o | L (k, v), o
| o, L (k, v) -> | o, L (k, v) ->
begin try begin try
let v' = find_exn k o in let v' = find_exn k o in
L (k, f k v v') L (k, f k v v')
with Not_found -> E with Not_found -> E
end end
| N (p1, m1, l1, r1), N (p2, m2, l2, r2) -> | N (p1, m1, l1, r1), N (p2, m2, l2, r2) ->
if p1 = p2 && m1 = m2 if p1 = p2 && m1 = m2
then mk_node_ p1 m1 (inter f l1 l2) (inter f r1 r2) then mk_node_ p1 m1 (inter f l1 l2) (inter f r1 r2)
else if Bit.gt m1 m2 && is_prefix_ ~prefix:p1 p2 ~bit:m1 else if Bit.gt m1 m2 && is_prefix_ ~prefix:p1 p2 ~bit:m1
then if Bit.is_0 p2 ~bit:m1 then if Bit.is_0 p2 ~bit:m1
then inter f l1 b then inter f l1 b
else inter f r1 b else inter f r1 b
else if Bit.lt m1 m2 && is_prefix_ ~prefix:p2 p1 ~bit:m2 else if Bit.lt m1 m2 && is_prefix_ ~prefix:p2 p1 ~bit:m2
then if Bit.is_0 p1 ~bit:m2 then if Bit.is_0 p1 ~bit:m2
then inter f a l2 then inter f a l2
else inter f a r2 else inter f a r2
else E else E
(*$R (*$R
assert_equal ~cmp:(equal ~eq:(=)) ~printer:(CCFormat.to_string (print CCString.print)) assert_equal ~cmp:(equal ~eq:(=)) ~printer:(CCFormat.to_string (print CCString.print))
@ -544,7 +544,7 @@ let print pp_x out m =
(* Some thorough tests from Jan Midtgaar (* Some thorough tests from Jan Midtgaar
https://github.com/jmid/qc-ptrees https://github.com/jmid/qc-ptrees
*) *)
(*$inject (*$inject
let test_count = 2_500 let test_count = 2_500
@ -684,14 +684,14 @@ let print pp_x out m =
(fun (t,k,v) -> (fun (t,k,v) ->
let s = interpret t in let s = interpret t in
abstract (add k v s) = add_m k v (abstract s)) abstract (add k v s) = add_m k v (abstract s))
*) *)
(*$QR & ~count:test_count (*$QR & ~count:test_count
(pair arb_tree arb_int) (pair arb_tree arb_int)
(fun (t,n) -> (fun (t,n) ->
let s = interpret t in let s = interpret t in
abstract (remove n s) = remove_m n (abstract s)) abstract (remove n s) = remove_m n (abstract s))
*) *)
(*$QR & ~count:test_count (*$QR & ~count:test_count
(pair arb_tree arb_tree) (pair arb_tree arb_tree)
@ -699,7 +699,7 @@ let print pp_x out m =
let s = interpret t in let s = interpret t in
let s' = interpret t' in let s' = interpret t' in
abstract (union merge_f s s') = union_m (abstract s) (abstract s')) abstract (union merge_f s s') = union_m (abstract s) (abstract s'))
*) *)
(*$QR & ~count:test_count (*$QR & ~count:test_count
Q.(pair arb_tree arb_tree) Q.(pair arb_tree arb_tree)

View file

@ -201,7 +201,7 @@ end
let g_char = map Char.chr (Char.code 'A' -- Char.code 'z') let g_char = map Char.chr (Char.code 'A' -- Char.code 'z')
let g_str = string_size ~gen:g_char (0--10) let g_str = string_size ~gen:g_char (0--10)
let a_str = {Q.string with Q.gen=g_str} let a_str = {Q.string with Q.gen=g_str}
*) *)
module MakeFromArray(A:Array.S) : S with module Array = A = struct module MakeFromArray(A:Array.S) : S with module Array = A = struct
module Array = A module Array = A
@ -638,9 +638,9 @@ module Make(Elt:sig
*) *)
(*$inject (*$inject
module BS = CCRingBuffer.Byte module BS = CCRingBuffer.Byte
type op = type op =
| Push_back of char | Push_back of char
| Take_front | Take_front
| Take_back | Take_back
@ -652,7 +652,7 @@ type op =
| Blit of string * int * int | Blit of string * int * int
| Z_if_full | Z_if_full
let str_of_op = function let str_of_op = function
| Push_back c -> Printf.sprintf "push_back(%C)" c | Push_back c -> Printf.sprintf "push_back(%C)" c
| Take_front -> Printf.sprintf "take_front" | Take_front -> Printf.sprintf "take_front"
| Take_back -> Printf.sprintf "take_back" | Take_back -> Printf.sprintf "take_back"
@ -664,15 +664,15 @@ let str_of_op = function
| Blit (s,i,len) -> Printf.sprintf "blit(%S,%d,%d)" s i len | Blit (s,i,len) -> Printf.sprintf "blit(%S,%d,%d)" s i len
| Z_if_full -> "zero_if_full" | Z_if_full -> "zero_if_full"
let push_back c = Push_back c let push_back c = Push_back c
let skip n = assert (n>=0); Skip n let skip n = assert (n>=0); Skip n
let blit s i len = let blit s i len =
if i<0 || len<0 || i+len > String.length s then ( if i<0 || len<0 || i+len > String.length s then (
failwith ("wrong blit: " ^ str_of_op (Blit (s,i,len))); failwith ("wrong blit: " ^ str_of_op (Blit (s,i,len)));
); );
Blit (s,i,len) Blit (s,i,len)
let shrink_op = let shrink_op =
let open Q.Iter in let open Q.Iter in
function function
| Push_back c -> Q.Shrink.char c >|= push_back | Push_back c -> Q.Shrink.char c >|= push_back
@ -695,14 +695,14 @@ let shrink_op =
in in
append s_i (append s_len s_s) append s_i (append s_len s_s)
let rec len_op size acc = function let rec len_op size acc = function
| Push_back _ -> min size (acc + 1) | Push_back _ -> min size (acc + 1)
| Take_front | Take_back | Junk_front | Junk_back -> max (acc-1) 0 | Take_front | Take_back | Junk_front | Junk_back -> max (acc-1) 0
| Skip n -> if acc >= n then acc-n else acc | Skip n -> if acc >= n then acc-n else acc
| Z_if_full | Peek_front | Peek_back -> acc | Z_if_full | Peek_front | Peek_back -> acc
| Blit (_,_,len) -> min size (acc + len) | Blit (_,_,len) -> min size (acc + len)
let apply_op b = function let apply_op b = function
| Push_back c -> BS.push_back b c; None | Push_back c -> BS.push_back b c; None
| Take_front -> BS.take_front b | Take_front -> BS.take_front b
| Take_back -> BS.take_back b | Take_back -> BS.take_back b
@ -716,7 +716,7 @@ let apply_op b = function
BS.blit_from b (Bytes.unsafe_of_string s) i len; None BS.blit_from b (Bytes.unsafe_of_string s) i len; None
| Z_if_full -> if BS.is_full b then Some '0' else None | Z_if_full -> if BS.is_full b then Some '0' else None
let gen_op = let gen_op =
let open Q.Gen in let open Q.Gen in
let g_blit = let g_blit =
string_size ~gen:g_char (5--20) >>= fun s -> string_size ~gen:g_char (5--20) >>= fun s ->
@ -738,15 +738,15 @@ let gen_op =
1, return Z_if_full; 1, return Z_if_full;
] ]
let arb_op = let arb_op =
Q.make Q.make
~shrink:shrink_op ~shrink:shrink_op
~print:str_of_op ~print:str_of_op
gen_op gen_op
let arb_ops = Q.list arb_op let arb_ops = Q.list arb_op
module L_impl = struct module L_impl = struct
type t = { type t = {
size: int; size: int;
mutable l: char list; mutable l: char list;
@ -796,12 +796,12 @@ module L_impl = struct
| Z_if_full -> if b.size = List.length b.l then Some '0' else None | Z_if_full -> if b.size = List.length b.l then Some '0' else None
let to_list b = b.l let to_list b = b.l
end end
*) *)
(* check that a lot of operations can be applied without failure, (* check that a lot of operations can be applied without failure,
and that the result has correct length *) and that the result has correct length *)
(*$QR & ~count:3_000 (*$QR & ~count:3_000
arb_ops (fun ops -> arb_ops (fun ops ->
let size = 64 in let size = 64 in

View file

@ -53,7 +53,7 @@ let pop q =
Q.(list small_int) (fun l -> \ Q.(list small_int) (fun l -> \
let q = of_list l in \ let q = of_list l in \
equal CCInt.equal (Gen.unfold pop q |> of_gen) q) equal CCInt.equal (Gen.unfold pop q |> of_gen) q)
*) *)
let junk q = let junk q =
try try
@ -180,7 +180,7 @@ let append q1 q2 =
equal CCInt.equal \ equal CCInt.equal \
(append (of_list l1)(of_list l2)) \ (append (of_list l1)(of_list l2)) \
(of_list (List.append l1 l2))) (of_list (List.append l1 l2)))
*) *)
module Infix = struct module Infix = struct
let (>|=) q f = map f q let (>|=) q f = map f q

View file

@ -17,7 +17,7 @@ let to_rev_list (l,r) = List.rev_append r l
(*$inject (*$inject
let zip_gen = Q.(pair (small_list int)(small_list int)) let zip_gen = Q.(pair (small_list int)(small_list int))
*) *)
(*$Q (*$Q
zip_gen (fun z -> \ zip_gen (fun z -> \