Skip to content

Commit 337fc79

Browse files
another conditional test
another conditional test back out sleep set override
1 parent 858271f commit 337fc79

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

tests/dune

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
(modules test_simple))
2020

2121
(test
22-
(name test_simple2)
22+
(name test_conditional1)
2323
(libraries dscheck)
24-
(modules test_simple2))
24+
(modules test_conditional1))
25+
26+
(test
27+
(name test_conditional2)
28+
(libraries dscheck)
29+
(modules test_conditional2))
File renamed without changes.

tests/test_conditional2.ml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module Atomic = Dscheck.TracedAtomic
2+
3+
let test () =
4+
let x = Atomic.make 0 in
5+
let y = Atomic.make 0 in
6+
let z = Atomic.make 0 in
7+
8+
let tmp = ref (-1) in
9+
Atomic.spawn (fun () -> tmp := Atomic.get x);
10+
Atomic.spawn (fun () -> Atomic.set y 1);
11+
12+
Atomic.spawn (fun () ->
13+
let m = Atomic.get y in
14+
if m = 0 then Atomic.set z 1);
15+
16+
Atomic.spawn (fun () ->
17+
let n = Atomic.get z in
18+
let l = Atomic.get y in
19+
if n = 1 then if l = 0 then Atomic.set x 1);
20+
21+
Atomic.final (fun () ->
22+
Format.printf "tmp=%d x=%d y=%d z=%d\n%!" !tmp (Atomic.get x)
23+
(Atomic.get y) (Atomic.get z))
24+
25+
let () = Atomic.trace test

0 commit comments

Comments
 (0)