Skip to content

Commit fb05a5f

Browse files
committed
add simple test
1 parent e027887 commit fb05a5f

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

tests/dune

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@
22
(name test_list)
33
(modules test_list)
44
(libraries dscheck))
5+
6+
(executable
7+
(name test_simple)
8+
(modules test_simple)
9+
(libraries dscheck))

tests/test_simple.ml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module Atomic = Dscheck.TracedAtomic
2+
3+
(* Example from ocaml-parrafuzz presentation at the OCaml Workshop 2021:
4+
https://www.youtube.com/watch?v=GZsUoSaIpIs *)
5+
6+
let test i =
7+
let x = Atomic.make i in
8+
let y = Atomic.make 0 in
9+
Atomic.spawn (fun () -> if Atomic.get x = 10 then Atomic.set y 2) ;
10+
Atomic.spawn (fun () -> Atomic.set x 0 ; Atomic.set y 1) ;
11+
Atomic.final (fun () -> Atomic.check (fun () -> Atomic.get y <> 2))
12+
13+
let () =
14+
Atomic.trace (fun () -> test 0) ;
15+
Printf.printf "\n-----------------------------\n\n%!" ;
16+
Atomic.trace (fun () -> test 10)

0 commit comments

Comments
 (0)