-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
112 additions
and
1 deletion.
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
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
Empty file.
Empty file.
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,59 @@ | ||
open Kcas_data | ||
|
||
module Spec = struct | ||
type cmd = Push of int | Pop_opt | Top_opt | Length | ||
|
||
let show_cmd = function | ||
| Push x -> "Push " ^ string_of_int x | ||
| Pop_opt -> "Pop_opt" | ||
| Top_opt -> "Top_opt" | ||
| Length -> "Length" | ||
|
||
type state = int list | ||
type sut = int Stack.t | ||
|
||
let arb_cmd _s = | ||
QCheck.( | ||
[ | ||
Gen.int |> Gen.map (fun x -> Push x); | ||
Gen.return Pop_opt; | ||
Gen.return Top_opt; | ||
Gen.return Length; | ||
] | ||
|> Gen.oneof |> make ~print:show_cmd) | ||
|
||
let init_state = [] | ||
let init_sut () = Stack.create () | ||
let cleanup _ = () | ||
|
||
let next_state c s = | ||
match c with | ||
| Push x -> x :: s | ||
| Pop_opt -> ( match s with [] -> [] | _ :: s -> s) | ||
| Top_opt -> s | ||
| Length -> s | ||
|
||
let precond _ _ = true | ||
|
||
let run c d = | ||
let open STM in | ||
match c with | ||
| Push x -> Res (unit, Stack.push x d) | ||
| Pop_opt -> Res (option int, Stack.pop_opt d) | ||
| Top_opt -> Res (option int, Stack.top_opt d) | ||
| Length -> Res (int, Stack.length d) | ||
|
||
let postcond c (s : state) res = | ||
let open STM in | ||
match (c, res) with | ||
| Push _x, Res ((Unit, _), ()) -> true | ||
| Pop_opt, Res ((Option Int, _), res) -> ( | ||
res = match s with [] -> None | x :: _ -> Some x) | ||
| Top_opt, Res ((Option Int, _), res) -> ( | ||
res = match s with [] -> None | x :: _ -> Some x) | ||
| Length, Res ((Int, _), res) -> res = List.length s | ||
| _, _ -> false | ||
end | ||
|
||
let () = | ||
Stm_run.run ~count:1000 ~verbose:true ~name:"Stack" (module Spec) |> exit |
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,8 @@ | ||
let run ~verbose ~count ~name (module Spec : STM.Spec) = | ||
let module Seq = STM_sequential.Make (Spec) in | ||
let module Con = STM_thread.Make (Spec) [@alert "-experimental"] in | ||
QCheck_base_runner.run_tests ~verbose | ||
[ | ||
Seq.agree_test ~count ~name:(name ^ " sequential"); | ||
Con.agree_test_conc ~count ~name:(name ^ " concurrent"); | ||
] |
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,8 @@ | ||
let run ~verbose ~count ~name (module Spec : STM.Spec) = | ||
let module Seq = STM_sequential.Make (Spec) in | ||
let module Dom = STM_domain.Make (Spec) in | ||
QCheck_base_runner.run_tests ~verbose | ||
[ | ||
Seq.agree_test ~count ~name:(name ^ " sequential"); | ||
Dom.agree_test_par ~count ~name:(name ^ " parallel"); | ||
] |