mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-05 19:00:31 -05:00
some tests for PiCalculus
This commit is contained in:
parent
3d199eeffb
commit
79dbf5e843
2 changed files with 35 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ let suite =
|
|||
"all_tests" >:::
|
||||
[ Test_pHashtbl.suite;
|
||||
Test_PersistentHashtbl.suite;
|
||||
Test_PiCalculus.suite;
|
||||
Test_splayMap.suite;
|
||||
Test_bij.suite;
|
||||
Test_leftistheap.suite;
|
||||
|
|
|
|||
34
tests/test_PiCalculus.ml
Normal file
34
tests/test_PiCalculus.ml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
|
||||
open OUnit
|
||||
|
||||
open PiCalculus
|
||||
module Pi = PiCalculus
|
||||
|
||||
let test_message () =
|
||||
let r = ref 0 in
|
||||
let p1 = new_
|
||||
(fun c ->
|
||||
send_one c 1 stop |||
|
||||
receive_one c (fun x -> r := x; stop))
|
||||
in
|
||||
Pi.run p1;
|
||||
OUnit.assert_equal ~printer:string_of_int 1 !r;
|
||||
()
|
||||
|
||||
let test_replicate () =
|
||||
let a = ref 0 in
|
||||
let b = ref 0 in
|
||||
let p1 = new_
|
||||
(fun c ->
|
||||
replicate (escape (fun () -> incr a; send_one c !a stop)) |||
|
||||
receive_one c (fun _ -> receive_one c (fun x -> b := x; stop)))
|
||||
in
|
||||
run p1;
|
||||
OUnit.assert_equal ~printer:string_of_int 2 !b;
|
||||
()
|
||||
|
||||
let suite =
|
||||
"test_PiCalculus" >:::
|
||||
[ "test_message" >:: test_message;
|
||||
"test_replicate" >:: test_replicate;
|
||||
]
|
||||
Loading…
Add table
Reference in a new issue