fix tests for containers.thread

This commit is contained in:
Simon Cruanes 2014-08-07 13:25:38 +02:00
parent e703a3f655
commit f2d027ac19
2 changed files with 8 additions and 7 deletions

6
_oasis
View file

@ -176,12 +176,12 @@ Executable test_lwt
BuildDepends: containers,lwt,lwt.unix,oUnit,containers.lwt BuildDepends: containers,lwt,lwt.unix,oUnit,containers.lwt
Executable test_threads Executable test_threads
Path: tests/lwt/ Path: tests/threads/
Install: false Install: false
CompiledObject: best CompiledObject: best
Build$: flag(tests) && flag(thread) Build$: flag(tests) && flag(thread)
MainIs: test_Future.ml MainIs: test_future.ml
BuildDepends: containers,threads,oUnit,containers.lwt BuildDepends: containers,threads,oUnit,containers.thread
Test all Test all
Command: make test-all Command: make test-all

View file

@ -3,6 +3,8 @@
open OUnit open OUnit
module Future = CCFuture
let test_mvar () = let test_mvar () =
let box = Future.MVar.empty () in let box = Future.MVar.empty () in
let f = Future.spawn (fun () -> Future.MVar.take box + 1) in let f = Future.spawn (fun () -> Future.MVar.take box + 1) in
@ -13,10 +15,9 @@ let test_mvar () =
() ()
let test_parallel () = let test_parallel () =
let open Gen.Infix in let l = CCSequence.(1 -- 300)
let l = 1 -- 300 |> CCSequence.map (fun _ -> Future.spawn (fun () -> Thread.delay 0.1; 1))
|> Gen.map (fun _ -> Future.spawn (fun () -> Thread.delay 0.1; 1)) |> CCSequence.to_list in
|> Gen.to_list in
let l' = List.map Future.get l in let l' = List.map Future.get l in
OUnit.assert_equal 300 (List.fold_left (+) 0 l'); OUnit.assert_equal 300 (List.fold_left (+) 0 l');
() ()