-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an internal test for STM on uncaught exceptions
- Loading branch information
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
random seed: 260395858 | ||
generated error fail pass / total time test name | ||
|
||
=== Error ====================================================================== | ||
|
||
Test STM test of uncaught exceptions errored on: | ||
|
||
AlwaysFail () | ||
|
||
|
||
exception Failure("unexpected") raised but not caught while running AlwaysFail () | ||
|
||
|
||
=== Error ====================================================================== | ||
|
||
Test neg STM test of uncaught exceptions errored on: | ||
|
||
AlwaysFail () | ||
|
||
|
||
exception Failure("unexpected") raised but not caught while running AlwaysFail () | ||
|
||
================================================================================ | ||
failure (0 tests failed, 2 tests errored, ran 2 tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
(* Test of the behaviour of STM tests with uncaught exceptions *) | ||
|
||
let always_fail () = failwith "unexpected" | ||
|
||
module UncaughtExcConf : STM.Spec = struct | ||
open STM | ||
|
||
type sut = unit | ||
type state = unit | ||
type cmd = AlwaysFail of sut | ||
|
||
let show_cmd = function AlwaysFail () -> "AlwaysFail ()" | ||
let arb_cmd _ = QCheck.(make ~print:show_cmd (Gen.pure (AlwaysFail ()))) | ||
let init_state = () | ||
let next_state _ _ = () | ||
let init_sut _ = () | ||
let cleanup _ = () | ||
let precond _ _ = true | ||
let run c s = match c with AlwaysFail () -> Res (unit, always_fail s) | ||
|
||
let postcond c _ r = | ||
match (c, r) with AlwaysFail (), Res ((Unit, _), _) -> true | _ -> false | ||
end | ||
|
||
module UE = STM_sequential.Make (UncaughtExcConf) | ||
|
||
let _ = | ||
QCheck_base_runner.run_tests_main | ||
[ | ||
UE.agree_test ~count:10 ~name:"STM test of uncaught exceptions"; | ||
UE.neg_agree_test ~count:10 ~name:"neg STM test of uncaught exceptions"; | ||
] |