merge from master

This commit is contained in:
Simon Cruanes 2014-09-30 17:12:59 +02:00
commit 7d3742e765
21 changed files with 170 additions and 158 deletions

View file

@ -62,9 +62,11 @@ QTESTABLE=$(filter-out $(DONTTEST), \
qtest-clean:
@rm -rf qtest/
QTEST_PREAMBLE='open CCFun;; '
qtest-build: qtest-clean build
@mkdir -p qtest
@qtest extract -o qtest/qtest_all.ml $(QTESTABLE) 2> /dev/null
@qtest extract --preamble $(QTEST_PREAMBLE) -o qtest/qtest_all.ml $(QTESTABLE) 2> /dev/null
@ocamlbuild $(OPTIONS) -pkg oUnit,QTest2Lib \
-I core -I misc -I string \
qtest/qtest_all.native

32
_oasis
View file

@ -44,10 +44,10 @@ Library "containers"
Path: core
Modules: CCVector, CCDeque, CCGen, CCSequence, CCFQueue, CCMultiMap,
CCMultiSet, CCBV, CCPrint, CCPersistentHashtbl, CCError,
CCHeap, CCList, CCOpt, CCPair, CCFun, CCHash, CCCat,
CCKList, CCInt, CCBool, CCArray, CCBatch, CCOrd, CCIO,
CCRandom, CCLinq, CCKTree, CCTrie, CCString, CCHashtbl,
CCFlatHashtbl
CCHeap, CCList, CCOpt, CCPair, CCFun, CCHash,
CCKList, CCInt, CCBool, CCArray, CCOrd, CCIO,
CCRandom, CCKTree, CCTrie, CCString, CCHashtbl,
CCFlatHashtbl, CCSexp
FindlibName: containers
Library "containers_string"
@ -57,6 +57,14 @@ Library "containers_string"
FindlibName: string
FindlibParent: containers
Library "containers_advanced"
Path: advanced
Pack: true
Modules: CCLinq, CCBatch, CCCat
FindlibName: advanced
FindlibParent: containers
BuildDepends: containers
Library "containers_pervasives"
Path: pervasives
Modules: CCPervasives
@ -70,7 +78,7 @@ Library "containers_misc"
Modules: Cache, FHashtbl, FlatHashtbl, Hashset,
Heap, LazyGraph, PersistentGraph,
PHashtbl, SkipList, SplayTree, SplayMap, Univ,
Bij, PiCalculus, Bencode, Sexp, RAL,
Bij, PiCalculus, Bencode, RAL,
UnionFind, SmallSet, AbsSet, CSM,
ActionMan, BencodeOnDisk, TTree, PrintBox,
HGraph, Automaton, Conv, Bidir, Iteratee, BTree,
@ -140,7 +148,7 @@ Executable benchs
CompiledObject: native
Build$: flag(bench)
MainIs: benchs.ml
BuildDepends: containers,containers.string,containers.misc,bench
BuildDepends: containers,containers.string,containers.misc,bench,containers.advanced
Executable bench_conv
Path: benchs/
@ -218,12 +226,12 @@ Executable lambda
BuildDepends: containers,containers.misc
Executable id_sexp
Path: examples/
Install: false
CompiledObject: native
MainIs: id_sexp.ml
Build$: flag(misc)
BuildDepends: containers,containers.misc
Path: examples/
Install: false
CompiledObject: native
MainIs: id_sexp.ml
Build$: flag(misc)
BuildDepends: containers
SourceRepository head
Type: git

View file

@ -173,25 +173,23 @@ module PMap = struct
);
}
let to_list m = m.to_seq |> CCSequence.to_rev_list
let to_list m = CCSequence.to_rev_list m.to_seq
let to_coll m = Seq m.to_seq
let reverse ~build m =
let build = make ~build () in
to_seq m
|> CCSequence.map (fun (x,y) -> y,x)
|> multimap_of_seq ~build
let seq = CCSequence.map (fun (x,y) -> y,x) (to_seq m) in
multimap_of_seq ~build seq
let reverse_multimap ~build m =
let build = make ~build () in
to_seq m
|> CCSequence.flatMap
(fun (x,l) ->
CCSequence.of_list l
|> CCSequence.map (fun y -> y,x)
)
|> multimap_of_seq ~build
let seq = to_seq m in
let seq = CCSequence.flat_map
(fun (x,l) -> CCSequence.map (fun y -> y,x) (CCSequence.of_list l)
) seq
in
multimap_of_seq ~build seq
end
type 'a search_result =
@ -280,7 +278,7 @@ module Coll = struct
| List [] -> fail ()
| List (x::_) -> x
| Seq s ->
begin match CCSequence.take 1 s |> CCSequence.to_list with
begin match CCSequence.to_list (CCSequence.take 1 s) with
| [x] -> x
| _ -> fail ()
end
@ -304,15 +302,14 @@ module Coll = struct
with MySurpriseExit -> ()
let take_while p c =
to_seq c |> _seq_take_while p |> of_seq
of_seq (_seq_take_while p (to_seq c))
let distinct ~cmp c = set_of_seq ~cmp (to_seq c)
let sort cmp c = match c with
| List l -> List (List.sort cmp l)
| Seq s -> List (List.sort cmp (CCSequence.to_rev_list s))
| _ ->
to_seq c |> set_of_seq ~cmp
| _ -> set_of_seq ~cmp (to_seq c)
let search obj c =
let _search_seq obj seq =
@ -327,7 +324,7 @@ module Coll = struct
| None -> obj#failure
| Some x -> x
in
to_seq c |> _search_seq obj
_search_seq obj (to_seq c)
let contains (type elt) ~eq x c = match c with
| List l -> List.exists (eq x) l
@ -336,17 +333,13 @@ module Coll = struct
let module S = (val m : CCSequence.Set.S
with type elt = elt and type t = 'b) in
(* XXX: here we don't use the equality relation *)
try
let y = S.find x set in
assert (eq x y);
true
with Not_found -> false
S.mem x set
let do_join ~join c1 c2 =
let build1 =
to_seq c1
|> CCSequence.map (fun x -> join.join_key1 x, x)
|> PMap.multimap_of_seq ~build:(PMap.make ~build:join.join_build ())
let seq = to_seq c1 in
let seq = CCSequence.map (fun x -> join.join_key1 x, x) seq in
PMap.multimap_of_seq ~build:(PMap.make ~build:join.join_build ()) seq
in
let l = CCSequence.fold
(fun acc y ->
@ -386,9 +379,8 @@ module Coll = struct
let build = PMap.make ~build () in
to_seq c1 (fun x -> PMap.add build x ());
to_seq c2 (fun x -> PMap.add build x ());
PMap.to_seq (PMap.build_get build)
|> CCSequence.map fst
|> of_seq
let seq = PMap.to_seq (PMap.build_get build) in
of_seq (CCSequence.map fst seq)
type inter_status =
| InterLeft
@ -415,9 +407,8 @@ module Coll = struct
to_seq c2 (fun x -> PMap.add build x ());
let map = PMap.build_get build in
(* output elements of [c1] not in [map] *)
to_seq c1
|> CCSequence.filter (fun x -> not (PMap.mem map x))
|> of_seq
let seq = to_seq c1 in
of_seq (CCSequence.filter (fun x -> not (PMap.mem map x)) seq)
end
(** {2 Query operators} *)
@ -487,7 +478,7 @@ let of_array a =
Start (Coll.of_array a)
let of_array_i a =
Start (CCSequence.of_array_i a |> Coll.of_seq)
Start (Coll.of_seq (CCSequence.of_array_i a))
let of_hashtbl h =
Start (Coll.of_seq (CCSequence.of_hashtbl h))
@ -496,13 +487,13 @@ let of_seq seq =
Start (Coll.of_seq seq)
let of_queue q =
Start (CCSequence.of_queue q |> Coll.of_seq)
Start (Coll.of_seq (CCSequence.of_queue q))
let of_stack s =
Start (CCSequence.of_stack s |> Coll.of_seq)
Start (Coll.of_seq (CCSequence.of_stack s))
let of_string s =
Start (CCSequence.of_str s |> Coll.of_seq)
Start (Coll.of_seq (CCSequence.of_str s))
(** {6 Execution} *)
@ -562,12 +553,11 @@ let _do_unary : type a b. (a,b) unary -> a -> b
| Fold (f, acc) -> Coll.fold f acc c
| FoldMap (f, acc) -> PMap.fold f acc c
| Reduce (safety, start, mix, stop) ->
let acc = Coll.to_seq c
|> CCSequence.fold
(fun acc x -> match acc with
| None -> Some (start x)
| Some acc -> Some (mix x acc)
) None
let acc = CCSequence.fold
(fun acc x -> match acc with
| None -> Some (start x)
| Some acc -> Some (mix x acc)
) None (Coll.to_seq c)
in
begin match acc, safety with
| Some x, Implicit -> stop x
@ -588,13 +578,11 @@ let _do_unary : type a b. (a,b) unary -> a -> b
| Get (Implicit, k) -> PMap.get_exn c k
| Get (Explicit, k) -> PMap.get_err c k
| GroupBy (build,f) ->
Coll.to_seq c
|> CCSequence.map (fun x -> f x, x)
|> PMap.multimap_of_seq ~build:(PMap.make ~build ())
let seq = CCSequence.map (fun x -> f x, x) (Coll.to_seq c) in
PMap.multimap_of_seq ~build:(PMap.make ~build ()) seq
| Contains (eq, x) -> Coll.contains ~eq x c
| Count build ->
Coll.to_seq c
|> PMap.count_of_seq ~build:(PMap.make ~build ())
PMap.count_of_seq ~build:(PMap.make ~build ()) (Coll.to_seq c)
| Lazy -> Lazy.force c
let _do_binary : type a b c. (a, b, c) binary -> a -> b -> c
@ -706,18 +694,20 @@ module M = struct
Unary (GeneralMap (fun m -> Coll.of_seq m.PMap.to_seq), q)
let flatten q =
let f m = m.PMap.to_seq
|> CCSequence.flatMap
(fun (k,v) -> Coll.to_seq v |> CCSequence.map (fun v' -> k,v'))
|> Coll.of_seq
let f m =
let seq = CCSequence.flat_map
(fun (k,v) -> CCSequence.map (fun v' -> k,v') (Coll.to_seq v))
m.PMap.to_seq
in Coll.of_seq seq
in
Unary (GeneralMap f, q)
let flatten' q =
let f m = m.PMap.to_seq
|> CCSequence.flatMap
(fun (k,v) -> CCSequence.of_list v |> CCSequence.map (fun v' -> k,v'))
|> Coll.of_seq
let f m =
let seq = CCSequence.flatMap
(fun (k,v) -> CCSequence.map (fun v' -> k,v') (CCSequence.of_list v))
m.PMap.to_seq
in Coll.of_seq seq
in
Unary (GeneralMap f, q)
@ -895,7 +885,7 @@ let to_array q =
QueryMap ((fun c -> Array.of_list (Coll.to_list c)), q)
let to_seq q =
QueryMap ((fun c -> Coll.to_seq c |> CCSequence.persistent), q)
QueryMap ((fun c -> CCSequence.persistent (Coll.to_seq c)), q)
let to_hashtbl q =
QueryMap ((fun c -> CCSequence.to_hashtbl (Coll.to_seq c)), q)
@ -919,9 +909,7 @@ module AdaptSet(S : Set.S) = struct
return (Coll.of_seq (fun k -> S.iter k set))
let to_set q =
let f c =
Coll.to_seq c |> CCSequence.fold (fun set x -> S.add x set) S.empty
in
let f c = CCSequence.fold (fun set x -> S.add x set) S.empty (Coll.to_seq c) in
query_map f q
let run q = run (to_set q)
@ -944,13 +932,12 @@ module AdaptMap(M : Map.S) = struct
let to_map q =
let f c =
Coll.to_seq c
|> CCSequence.fold (fun m (x,y) -> M.add x y m) M.empty
CCSequence.fold (fun m (x,y) -> M.add x y m) M.empty (Coll.to_seq c)
in
query_map f q
let run q = run (q |> to_map)
let run_exn q = run_exn (q |> to_map)
let run q = run (to_map q)
let run_exn q = run_exn (to_map q)
end
module IO = struct
@ -1017,20 +1004,21 @@ module IO = struct
let lines q =
(* sequence of lines *)
let f s = _lines s 0 |> Coll.of_seq in
let f s = Coll.of_seq (_lines s 0) in
query_map f q
let lines' q =
let f s = lazy (_lines s 0 |> CCSequence.to_list) in
let f s = lazy (CCSequence.to_list (_lines s 0)) in
lazy_ (query_map f q)
let _join ~sep ?(stop="") l =
let buf = Buffer.create 128 in
Coll.to_seq l
|> CCSequence.iteri
(fun i x ->
if i>0 then Buffer.add_string buf sep;
Buffer.add_string buf x);
let seq = Coll.to_seq l in
CCSequence.iteri
(fun i x ->
if i>0 then Buffer.add_string buf sep;
Buffer.add_string buf x)
seq;
Buffer.add_string buf stop;
Buffer.contents buf
@ -1043,12 +1031,11 @@ module IO = struct
lazy_ (query_map f q)
let out oc q =
run_exn q |> output_string oc
output_string oc (run_exn q)
let out_lines oc q =
run_exn q
|> Coll.to_seq
|> CCSequence.iter (fun l -> output_string oc l; output_char oc '\n')
let x = run_exn q in
CCSequence.iter (fun l -> output_string oc l; output_char oc '\n') (Coll.to_seq x)
let to_file_exn filename q =
_with_file_out filename (fun oc -> out oc q)

View file

@ -1,5 +1,7 @@
(** benchmark CCBatch *)
open Containers_advanced
module type COLL = sig
val name : string
include CCBatch.COLLECTION

View file

@ -78,6 +78,7 @@ let () =
Printf.printf "list of 5 elements...\n";
bench_list [1,2; 3,4; 5,6; 7,8; 9,10];
let open CCFun in
let l = CCGen.(1 -- 100 |> map (fun x->x,x) |> to_rev_list) in
Printf.printf "list of %d elements...\n" (List.length l);
bench_list l;

View file

@ -28,7 +28,7 @@ let rec eq t1 t2 = match t1, t2 with
let rec hash_tree t h = match t with
| Empty -> CCHash.string_ "empty" h
| Node (i, l) ->
h |> CCHash.string_ "node" |> CCHash.int_ i |> CCHash.list_ hash_tree l
CCHash.list_ hash_tree l (CCHash.int_ i (CCHash.string_ "node" h))
module Box = Containers_misc.PrintBox

View file

@ -471,17 +471,17 @@ module File = struct
if Sys.is_directory d
then
let arr = Sys.readdir d in
Seq.of_array arr
|> Seq.map_pure make
Seq.map_pure make (Seq.of_array arr)
else Seq.empty
let rec _walk d () =
if Sys.is_directory d
then
let arr = Sys.readdir d in
let tail = Seq.of_array arr
|> Seq.flat_map
(fun s -> return (_walk (Filename.concat d s) ()))
let tail = Seq.of_array arr in
let tail = Seq.flat_map
(fun s -> return (_walk (Filename.concat d s) ()))
tail
in Seq.cons (`Dir,d) tail
else Seq.singleton (`File, d)
@ -501,14 +501,14 @@ module File = struct
if Sys.is_directory d
then
let arr = Sys.readdir d in
Seq.of_array arr
|> Seq.map_pure (fun s -> Filename.concat d s)
|> Seq.flat_map
let arr = Seq.of_array arr in
let arr = Seq.map_pure (fun s -> Filename.concat d s) arr in
Seq.flat_map
(fun s ->
if Sys.is_directory s
then return (_read_dir_rec s ())
else return (Seq.singleton s)
)
) arr
else Seq.empty
end

View file

@ -178,7 +178,7 @@ let find ?pset f t =
| None -> _find_kl f l'
| Some _ as res -> res
in
bfs ?pset t |> _find_kl f
_find_kl f (bfs ?pset t)
(** {2 Pretty printing in the DOT (graphviz) format} *)

View file

@ -29,9 +29,10 @@ type 'a or_error = [ `Ok of 'a | `Error of string ]
type 'a sequence = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type t =
| Atom of string
| List of t list
type t = [
| `Atom of string
| `List of t list
]
let equal a b = a = b
@ -39,19 +40,21 @@ let compare a b = Pervasives.compare a b
let hash a = Hashtbl.hash a
let of_int x = Atom (string_of_int x)
let of_float x = Atom (string_of_float x)
let of_bool x = Atom (string_of_bool x)
let of_string x = Atom x
let of_unit = List []
let of_list l = List l
let of_pair (x,y) = List[x;y]
let of_triple (x,y,z) = List[x;y;z]
let of_int x = `Atom (string_of_int x)
let of_float x = `Atom (string_of_float x)
let of_bool x = `Atom (string_of_bool x)
let atom x = `Atom x
let of_unit = `List []
let of_list l = `List l
let of_rev_list l = `List (List.rev l)
let of_pair (x,y) = `List[x;y]
let of_triple (x,y,z) = `List[x;y;z]
let of_quad (x,y,z,u) = `List[x;y;z;u]
let of_variant name args = List (Atom name :: args)
let of_field name t = List [Atom name; t]
let of_variant name args = `List (`Atom name :: args)
let of_field name t = `List [`Atom name; t]
let of_record l =
List (List.map (fun (n,x) -> of_field n x) l)
`List (List.map (fun (n,x) -> of_field n x) l)
let _with_in filename f =
let ic = open_in filename in
@ -89,11 +92,11 @@ let _must_escape s =
with Exit -> true
let rec to_buf b t = match t with
| Atom s when _must_escape s -> Printf.bprintf b "\"%s\"" (String.escaped s)
| Atom s -> Buffer.add_string b s
| List [] -> Buffer.add_string b "()"
| List [x] -> Printf.bprintf b "(%a)" to_buf x
| List l ->
| `Atom s when _must_escape s -> Printf.bprintf b "\"%s\"" (String.escaped s)
| `Atom s -> Buffer.add_string b s
| `List [] -> Buffer.add_string b "()"
| `List [x] -> Printf.bprintf b "(%a)" to_buf x
| `List l ->
Buffer.add_char b '(';
List.iteri
(fun i t' -> (if i > 0 then Buffer.add_char b ' '; to_buf b t'))
@ -106,11 +109,11 @@ let to_string t =
Buffer.contents b
let rec print fmt t = match t with
| Atom s when _must_escape s -> Format.fprintf fmt "\"%s\"" (String.escaped s)
| Atom s -> Format.pp_print_string fmt s
| List [] -> Format.pp_print_string fmt "()"
| List [x] -> Format.fprintf fmt "@[<hov2>(%a)@]" print x
| List l ->
| `Atom s when _must_escape s -> Format.fprintf fmt "\"%s\"" (String.escaped s)
| `Atom s -> Format.pp_print_string fmt s
| `List [] -> Format.pp_print_string fmt "()"
| `List [x] -> Format.fprintf fmt "@[<hov2>(%a)@]" print x
| `List l ->
Format.open_hovbox 2;
Format.pp_print_char fmt '(';
List.iteri
@ -120,11 +123,11 @@ let rec print fmt t = match t with
Format.close_box ()
let rec print_noindent fmt t = match t with
| Atom s when _must_escape s -> Format.fprintf fmt "\"%s\"" (String.escaped s)
| Atom s -> Format.pp_print_string fmt s
| List [] -> Format.pp_print_string fmt "()"
| List [x] -> Format.fprintf fmt "(%a)" print_noindent x
| List l ->
| `Atom s when _must_escape s -> Format.fprintf fmt "\"%s\"" (String.escaped s)
| `Atom s -> Format.pp_print_string fmt s
| `List [] -> Format.pp_print_string fmt "()"
| `List [x] -> Format.fprintf fmt "(%a)" print_noindent x
| `List l ->
Format.pp_print_char fmt '(';
List.iteri
(fun i t' -> (if i > 0 then Format.pp_print_char fmt ' '; print_noindent fmt t'))
@ -468,7 +471,7 @@ let _error ps msg =
let rec _next ps : t partial_result =
match Lexer.next ps.ps_d with
| `Ok (Lexer.Atom s) ->
_push ps (Atom s)
_push ps (`Atom s)
| `Ok Lexer.Open ->
ps.ps_stack <- [] :: ps.ps_stack;
_next ps
@ -477,7 +480,7 @@ let rec _next ps : t partial_result =
| [] -> _error ps "unbalanced ')'"
| l :: stack ->
ps.ps_stack <- stack;
_push ps (List (List.rev l))
_push ps (`List (List.rev l))
end
| `Error msg -> `Error msg
| `Await -> `Await
@ -598,8 +601,8 @@ module Traverse = struct
| None -> _list_any f tl
let list_any f e = match e with
| Atom _ -> None
| List l -> _list_any f l
| `Atom _ -> None
| `List l -> _list_any f l
let rec _list_all f acc l = match l with
| [] -> List.rev acc
@ -609,12 +612,12 @@ module Traverse = struct
| None -> _list_all f acc tl
let list_all f e = match e with
| Atom _ -> []
| List l -> _list_all f [] l
| `Atom _ -> []
| `List l -> _list_all f [] l
let _try_atom e f = match e with
| List _ -> None
| Atom x -> try Some (f x) with _ -> None
| `List _ -> None
| `Atom x -> try Some (f x) with _ -> None
let to_int e = _try_atom e int_of_string
let to_bool e = _try_atom e bool_of_string
@ -622,25 +625,25 @@ module Traverse = struct
let to_string e = _try_atom e (fun x->x)
let to_pair e = match e with
| List [x;y] -> Some (x,y)
| `List [x;y] -> Some (x,y)
| _ -> None
let to_triple e = match e with
| List [x;y;z] -> Some (x,y,z)
| `List [x;y;z] -> Some (x,y,z)
| _ -> None
let to_list e = match e with
| List l -> Some l
| Atom _ -> None
| `List l -> Some l
| `Atom _ -> None
let rec _get_field name l = match l with
| List [Atom n; x] :: _ when name=n -> Some x
| `List [`Atom n; x] :: _ when name=n -> Some x
| _ :: tl -> _get_field name tl
| [] -> None
let get_field name e = match e with
| List l -> _get_field name l
| Atom _ -> None
| `List l -> _get_field name l
| `Atom _ -> None
let field name f e =
get_field name e >>= f
@ -651,9 +654,9 @@ module Traverse = struct
| _ :: tl -> _get_variant s args tl
let get_variant l e = match e with
| List (Atom s :: args) -> _get_variant s args l
| List _ -> None
| Atom s -> _get_variant s [] l
| `List (`Atom s :: args) -> _get_variant s args l
| `List _ -> None
| `Atom s -> _get_variant s [] l
let get_exn e = match e with
| None -> failwith "Sexp.Traverse.get_exn"

View file

@ -33,26 +33,30 @@ type 'a gen = unit -> 'a option
(** {2 Basics} *)
type t =
| Atom of string
| List of t list
type t = [
| `Atom of string
| `List of t list
]
val equal : t -> t -> bool
val compare : t -> t -> int
val hash : t -> int
val atom : string -> t (** Build an atom directly from a string *)
val of_int : int -> t
val of_bool : bool -> t
val of_list : t list -> t
val of_string : string -> t
val of_rev_list : t list -> t (** Reverse the list *)
val of_float : float -> t
val of_unit : t
val of_pair : t * t -> t
val of_triple : t * t * t -> t
val of_quad : t * t * t * t -> t
val of_variant : string -> t list -> t
(** [of_variant name args] is used to encode algebraic variants
into a S-expr. For instance [of_variant "some" (of_int 1)]
into a S-expr. For instance [of_variant "some" [of_int 1]]
represents the value [Some 1] *)
val of_field : string -> t -> t

View file

@ -471,13 +471,14 @@ module Make(W : WORD) = struct
else None, alternatives
| Some (Node (_, map), trail) ->
let alternatives =
_seq_map map
|> _filter_map_seq
let seq = _seq_map map in
let seq = _filter_map_seq
(fun (c', t') -> if p c c'
then Some (t', _difflist_add trail c')
else None
)
|> _seq_append_list alternatives
) seq
in
_seq_append_list alternatives seq
in
begin try
let t' = M.find c map in

View file

@ -3,11 +3,11 @@
let () =
if Array.length Sys.argv <> 2 then failwith "usage: id_sexp file";
let f = Sys.argv.(1) in
let s = Sexp.L.of_file f in
let s = CCSexp.L.of_file f in
match s with
| `Ok l ->
List.iter
(fun s -> Format.printf "@[%a@]@." Sexp.print s)
(fun s -> Format.printf "@[%a@]@." CCSexp.print s)
l
| `Error msg ->
Format.printf "error: %s@." msg

View file

@ -546,6 +546,8 @@ end
(* tests *)
let (@@) f x = f x
module Point = struct
type t = {
x : int;

View file

@ -1,5 +1,6 @@
open OUnit
open CCFun
module Gen = CCGen
module GR = Gen.Restart

View file

@ -1,6 +1,7 @@
(* quickcheck for Levenshtein *)
module Levenshtein = Containers_string.Levenshtein
open CCFun
(* test that automaton accepts its string *)
let test_automaton =

View file

@ -15,9 +15,9 @@ let test_mvar () =
()
let test_parallel () =
let l = CCSequence.(1 -- 300)
|> CCSequence.map (fun _ -> Future.spawn (fun () -> Thread.delay 0.1; 1))
|> CCSequence.to_list in
let l = CCSequence.(1 -- 300) in
let l = CCSequence.map (fun _ -> Future.spawn (fun () -> Thread.delay 0.1; 1)) l in
let l = CCSequence.to_list l in
let l' = List.map Future.get l in
OUnit.assert_equal 300 (List.fold_left (+) 0 l');
()