Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
n-osborne committed Oct 13, 2023
1 parent bfd31ee commit 7649205
Show file tree
Hide file tree
Showing 19 changed files with 651 additions and 7 deletions.
4 changes: 3 additions & 1 deletion dune-project
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(lang dune 3.0)
(lang dune 3.8)
(using dune_site 0.1)
(using mdx 0.4)

(name ortac)

(package
Expand Down
2 changes: 1 addition & 1 deletion ortac-core.opam
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ build: [

depends: [
"ocaml" {>= "4.11.0"}
"dune" {>= "3.0"}
"dune" {>= "3.8"}
"dune-site"
"cmdliner" {>= "1.1.0"}
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion ortac-monolith.opam
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ build: [

depends: [
"ocaml" {>= "4.11.0"}
"dune" {>= "3.0"}
"dune" {>= "3.8"}
"cmdliner" {>= "1.1.0"}
"fmt"
"ppxlib" {>= "0.26.0"}
Expand Down
3 changes: 2 additions & 1 deletion ortac-qcheck-stm.opam
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ build: [

depends: [
"ocaml" {>= "4.11.0"}
"dune" {>= "3.0"}
"dune" {>= "3.8"}
"cmdliner" {>= "1.1.0"}
"fmt"
"ppxlib" {>= "0.26.0"}
"mdx" {with-test}
"gospel" {>= "0.2.0"}
"qcheck-core" {with-test}
"qcheck-stm" {with-test}
Expand Down
2 changes: 1 addition & 1 deletion ortac-runtime-monolith.opam
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ build: [

depends: [
"ocaml" {>= "4.11.0"}
"dune" {>= "3.0"}
"dune" {>= "3.8"}
"monolith" {>= "20201026"}
"pprint"
"fmt" {>= "0.9.0"}
Expand Down
2 changes: 1 addition & 1 deletion ortac-runtime.opam
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ doc: "https://pascutto.github.io/ortac/"
bug-reports: "https://github.com/ocaml-gospel/ortac/issues"
depends: [
"ocaml" {>= "4.11.0"}
"dune" {>= "3.0"}
"dune" {>= "3.8"}
"fmt"
"zarith"
"monolith" {with-test}
Expand Down
2 changes: 1 addition & 1 deletion ortac-wrapper.opam
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ build: [

depends: [
"ocaml" {>= "4.11.0"}
"dune" {>= "3.0"}
"dune" {>= "3.8"}
"dune-site"
"cmdliner" {>= "1.1.0"}
"fmt"
Expand Down
21 changes: 21 additions & 0 deletions plugins/qcheck-stm/doc/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(mdx
(package ortac-qcheck-stm)
(deps
(package ortac-core)))

(documentation
(package ortac-qcheck-stm)
(mld_files index))

(rule
(alias runtest)
(package ortac-qcheck-stm)
(deps
(:example example.mli)
(package gospel))
(action
(setenv
ORTAC_ONLY_PLUGIN
qcheck-stm
(ignore-outputs
(run gospel check %{example})))))
36 changes: 36 additions & 0 deletions plugins/qcheck-stm/doc/example.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
(* $MDX part-begin=type-decl *)

type 'a t
(*@ model size : int
mutable model contents : 'a list *)

(* $MDX part-end *)

(* $MDX part-begin=make *)

val make : int -> 'a -> 'a t
(*@ t = make i a
checks i >= 0
ensures t.size = i
ensures t.contents = List.init i (fun j -> a) *)

(* $MDX part-end *)

(* $MDX part-begin=set *)

val set : 'a t -> int -> 'a -> unit
(*@ set t i a
checks 0 <= i < t.size
modifies t.contents
ensures t.contents = List.mapi (fun j x -> if j = (i : integer) then a else x) (old t.contents) *)

(* $MDX part-end *)

(* $MDX part-begin=get *)

val get : 'a t -> int -> 'a
(*@ a = get t i
checks 0 <= i < t.size
ensures a = List.nth t.contents i *)

(* $MDX part-end *)
17 changes: 17 additions & 0 deletions plugins/qcheck-stm/doc/example_for_all.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
type 'a t
(*@ model size : int
mutable model contents : 'a list *)

val make : int -> 'a -> 'a t
(*@ t = make i a
checks i >= 0
ensures t.size = i
ensures t.contents = List.init i (fun j -> a) *)

(* $MDX part-begin=fun-decl *)

val for_all : 'a t -> bool
(*@ b = for_all t
ensures b = List.for_all (fun x -> x = x) t.contents *)

(* $MDX part-end *)
16 changes: 16 additions & 0 deletions plugins/qcheck-stm/doc/example_ghost.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
type 'a t
(*@ model size : int
mutable model contents : 'a list *)

val make : int -> 'a -> 'a t
(*@ t = make i a
checks i >= 0
ensures t.size = i
ensures t.contents = List.init i (fun j -> a) *)

(* $MDX part-begin=fun-decl *)

val incompatible_type : char -> string t -> bool
(*@ b = incompatible_type c t *)

(* $MDX part-end *)
17 changes: 17 additions & 0 deletions plugins/qcheck-stm/doc/example_ill_formed_quantification.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
type 'a t
(*@ model size : int
mutable model contents : 'a list *)

val make : int -> 'a -> 'a t
(*@ t = make i a
checks i >= 0
ensures t.size = i
ensures t.contents = List.init i (fun j -> a) *)

(* $MDX part-begin=fun-decl *)

val unsupported_quantification : 'a t -> bool
(*@ b = unsupported_quantification t
ensures b = forall a. List.mem a t.contents -> a = a *)

(* $MDX part-end *)
16 changes: 16 additions & 0 deletions plugins/qcheck-stm/doc/example_incompatible_type.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
type 'a t
(*@ model size : int
mutable model contents : 'a list *)

val make : int -> 'a -> 'a t
(*@ t = make i a
checks i >= 0
ensures t.size = i
ensures t.contents = List.init i (fun j -> a) *)

(* $MDX part-begin=fun-decl *)

val incompatible_type : char -> string t -> bool
(*@ b = incompatible_type c t *)

(* $MDX part-end *)
18 changes: 18 additions & 0 deletions plugins/qcheck-stm/doc/example_next_state.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
type 'a t
(*@ model size : int
mutable model contents : 'a list *)

val make : int -> 'a -> 'a t
(*@ t = make i a
checks i >= 0
ensures t.size = i
ensures t.contents = List.init i (fun j -> a) *)

(* $MDX part-begin=fun-decl *)

val ensures_not_found_for_next_state : 'a t -> unit
(*@ ensures_not_found_for_next_state t
modifies t.contents
ensures List.length t.contents = List.length (old t.contents) *)

(* $MDX part-end *)
25 changes: 25 additions & 0 deletions plugins/qcheck-stm/doc/example_sut.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
type 'a t
(*@ model size : int
mutable model contents : 'a list *)

val make : int -> 'a -> 'a t
(*@ t = make i a
checks i >= 0
ensures t.size = i
ensures t.contents = List.init i (fun j -> a) *)

(* $MDX part-begin=fun-decl *)

val f : int -> int -> bool
(*@ b = f x y *)

val g : 'a t -> 'a t -> bool
(*@ b = g t1 t2 *)

val h : int -> 'a t
(*@ t = h i *)

val exist : ('a -> bool) -> 'a t -> b
(*@ b = exist p t *)

(* $MDX part-end *)
18 changes: 18 additions & 0 deletions plugins/qcheck-stm/doc/example_unknown_type.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
type 'a t
(*@ model size : int
mutable model contents : 'a list *)

val make : int -> 'a -> 'a t
(*@ t = make i a
checks i >= 0
ensures t.size = i
ensures t.contents = List.init i (fun j -> a) *)

type new_type

(* $MDX part-begin=fun-decl *)

val type_not_supported : new_type -> 'a t -> new_type
(*@ y = type_not_supported x t *)

(* $MDX part-end *)
Loading

0 comments on commit 7649205

Please sign in to comment.