fix(pool): missing emptiness check in Fut.map_l

also add regression test
This commit is contained in:
Simon Cruanes 2020-07-28 16:27:02 -04:00
parent 30b9307a70
commit 39e0ad2395

View file

@ -530,9 +530,17 @@ module Make(P : PARAM) = struct
(* reverse twice *) (* reverse twice *)
let map_l f l = let map_l f l =
let l = List.rev_map f l in match l with
sequence_ (L_ l) | [] -> return []
(fun () -> List.rev_map get_nolock_ l) | _ ->
let l = List.rev_map f l in
sequence_ (L_ l)
(fun () -> List.rev_map get_nolock_ l)
(*$=
[2;3] (Fut.get @@ Fut.map_l (fun x -> Fut.return (x+1)) [1;2])
[] (Fut.get @@ Fut.map_l (fun x -> Fut.return (x+1)) [])
*)
(*$R (*$R
let l = CCList.(1 -- 50) in let l = CCList.(1 -- 50) in