Skip to content

Commit

Permalink
another conditional test
Browse files Browse the repository at this point in the history
another conditional test

back out sleep set override
  • Loading branch information
bartoszmodelski committed Apr 5, 2023
1 parent 858271f commit 337fc79
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/dune
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
(modules test_simple))

(test
(name test_simple2)
(name test_conditional1)
(libraries dscheck)
(modules test_simple2))
(modules test_conditional1))

(test
(name test_conditional2)
(libraries dscheck)
(modules test_conditional2))
File renamed without changes.
25 changes: 25 additions & 0 deletions tests/test_conditional2.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module Atomic = Dscheck.TracedAtomic

let test () =
let x = Atomic.make 0 in
let y = Atomic.make 0 in
let z = Atomic.make 0 in

let tmp = ref (-1) in
Atomic.spawn (fun () -> tmp := Atomic.get x);
Atomic.spawn (fun () -> Atomic.set y 1);

Atomic.spawn (fun () ->
let m = Atomic.get y in
if m = 0 then Atomic.set z 1);

Atomic.spawn (fun () ->
let n = Atomic.get z in
let l = Atomic.get y in
if n = 1 then if l = 0 then Atomic.set x 1);

Atomic.final (fun () ->
Format.printf "tmp=%d x=%d y=%d z=%d\n%!" !tmp (Atomic.get x)
(Atomic.get y) (Atomic.get z))

let () = Atomic.trace test

0 comments on commit 337fc79

Please sign in to comment.