Skip to content

Commit c9c70c9

Browse files
committed
Add an internal test for Lin on uncaught exceptions
1 parent 765a973 commit c9c70c9

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

test/dune

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,17 @@
5454
(libraries qcheck-stm.sequential threads.posix)
5555
(action
5656
(with-accepted-exit-codes 1 (run ./%{test} --verbose --seed 229109553))))
57+
58+
(test
59+
(name uncaught_lin)
60+
(package qcheck-lin)
61+
(modules uncaught_lin)
62+
(libraries qcheck-lin.domain)
63+
(enabled_if (>= %{ocaml_version} 5))
64+
(action
65+
(pipe-outputs
66+
(with-accepted-exit-codes 1
67+
(run %{test} --no-colors --verbose --seed 260395858))
68+
; filter out output that is not deterministic enough across
69+
; versions and platforms
70+
(run sed -e "/^[[]/d" -e "s/ ([0-9]* shrink steps)//"))))

test/uncaught_lin.expected

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
random seed: 260395858
2+
generated error fail pass / total time test name
3+
4+
=== Error ======================================================================
5+
6+
Test Lin DSL test of uncaught exceptions errored on:
7+
8+
|
9+
always_fail t
10+
|
11+
.---------------------.
12+
| |
13+
14+
15+
exception Failure("unexpected") raised but not caught while running always_fail t
16+
17+
18+
=== Error ======================================================================
19+
20+
Test neg Lin DSL test of uncaught exceptions errored on:
21+
22+
|
23+
always_fail t
24+
|
25+
.---------------------.
26+
| |
27+
28+
29+
exception Failure("unexpected") raised but not caught while running always_fail t
30+
31+
================================================================================
32+
failure (0 tests failed, 2 tests errored, ran 2 tests)

test/uncaught_lin.ml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
(* Test of the behaviour of Lin tests with uncaught exceptions *)
2+
3+
let always_fail () = failwith "unexpected"
4+
5+
module UncaughtExcConf = struct
6+
open Lin
7+
8+
type t = unit
9+
10+
let init () = ()
11+
let cleanup _ = ()
12+
let api = [ val_ "always_fail" always_fail (t @-> returning unit) ]
13+
end
14+
15+
module UncaughtExc_domain = Lin_domain.Make (UncaughtExcConf)
16+
17+
let _ =
18+
QCheck_base_runner.run_tests_main
19+
[
20+
UncaughtExc_domain.lin_test ~count:10
21+
~name:"Lin DSL test of uncaught exceptions";
22+
UncaughtExc_domain.neg_lin_test ~count:10
23+
~name:"neg Lin DSL test of uncaught exceptions";
24+
]

0 commit comments

Comments
 (0)