mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-09 04:35:29 -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
|
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
|
||||||
|
|
|
||||||
|
|
@ -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');
|
||||||
()
|
()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue