Skip to content

Commit d0c0803

Browse files
committed
use alcotest
1 parent 7fa6a54 commit d0c0803

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

tests/dune

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
(test
1212
(name test_simple)
13-
(libraries dscheck)
13+
(libraries dscheck alcotest)
1414
(modules test_simple))
1515

1616
(test
1717
(name test_bug)
18-
(libraries dscheck)
18+
(libraries dscheck alcotest)
1919
(modules test_bug))

tests/test_bug.ml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,17 @@ let test () =
1414
assert (Atomic.get cancelled) (* This bug should be detected *)
1515
)
1616

17-
let () = Atomic.trace test
17+
let test () =
18+
match Atomic.trace test with
19+
| exception _ -> ()
20+
| _ -> failwith "expected failure"
21+
22+
let () =
23+
let open Alcotest in
24+
run "dscheck"
25+
[
26+
( "bug",
27+
[
28+
test_case "test" `Quick test;
29+
] );
30+
]

tests/test_simple.ml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,20 @@ let test i =
1212
Atomic.set y 1 ;
1313
Atomic.final (fun () -> Atomic.check (fun () -> Atomic.get y <> 2))
1414

15+
let test_0 () = Atomic.trace (fun () -> test 0)
16+
17+
let test_10 () =
18+
match Atomic.trace (fun () -> test 10) with
19+
| exception _ -> ()
20+
| _ -> failwith "expected failure"
21+
1522
let () =
16-
Atomic.trace (fun () -> test 0) ;
17-
Printf.printf "\n-----------------------------\n\n%!" ;
18-
Atomic.trace (fun () -> test 10)
23+
let open Alcotest in
24+
run "dscheck"
25+
[
26+
( "simple",
27+
[
28+
test_case "test-0" `Quick test_0;
29+
test_case "test-10" `Quick test_10;
30+
] );
31+
]

0 commit comments

Comments
 (0)