mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-08 20:25:28 -05:00
fix tests for containers.thread
This commit is contained in:
parent
e703a3f655
commit
f2d027ac19
2 changed files with 8 additions and 7 deletions
6
_oasis
6
_oasis
|
|
@ -176,12 +176,12 @@ Executable test_lwt
|
|||
BuildDepends: containers,lwt,lwt.unix,oUnit,containers.lwt
|
||||
|
||||
Executable test_threads
|
||||
Path: tests/lwt/
|
||||
Path: tests/threads/
|
||||
Install: false
|
||||
CompiledObject: best
|
||||
Build$: flag(tests) && flag(thread)
|
||||
MainIs: test_Future.ml
|
||||
BuildDepends: containers,threads,oUnit,containers.lwt
|
||||
MainIs: test_future.ml
|
||||
BuildDepends: containers,threads,oUnit,containers.thread
|
||||
|
||||
Test all
|
||||
Command: make test-all
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
open OUnit
|
||||
|
||||
module Future = CCFuture
|
||||
|
||||
let test_mvar () =
|
||||
let box = Future.MVar.empty () in
|
||||
let f = Future.spawn (fun () -> Future.MVar.take box + 1) in
|
||||
|
|
@ -13,10 +15,9 @@ let test_mvar () =
|
|||
()
|
||||
|
||||
let test_parallel () =
|
||||
let open Gen.Infix in
|
||||
let l = 1 -- 300
|
||||
|> Gen.map (fun _ -> Future.spawn (fun () -> Thread.delay 0.1; 1))
|
||||
|> Gen.to_list in
|
||||
let l = CCSequence.(1 -- 300)
|
||||
|> CCSequence.map (fun _ -> Future.spawn (fun () -> Thread.delay 0.1; 1))
|
||||
|> CCSequence.to_list in
|
||||
let l' = List.map Future.get l in
|
||||
OUnit.assert_equal 300 (List.fold_left (+) 0 l');
|
||||
()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue