Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for exceptional behaviour to printing runnable scenario #206

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

- Improve test-failure message
[\#202](https://github.com/ocaml-gospel/ortac/pull/202) and
[\#204](https://github.com/ocaml-gospel/ortac/pull/204)
[\#204](https://github.com/ocaml-gospel/ortac/pull/204) and
[\#206](https://github.com/ocaml-gospel/ortac/pull/206)
- Add a comment warning that the file is generated
[\#198](https://github.com/ocaml-gospel/ortac/pull/198)
- Add support for type invariants
Expand Down
24 changes: 12 additions & 12 deletions examples/lwt_dllist_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ module Spec =
Format.asprintf "%s %a sut" "add_l" (Util.Pp.pp_int true) a_1
| Add_r a_2 ->
Format.asprintf "%s %a sut" "add_r" (Util.Pp.pp_int true) a_2
| Take_l -> Format.asprintf "%s sut" "take_l"
| Take_r -> Format.asprintf "%s sut" "take_r"
| Take_l -> Format.asprintf "protect (fun () -> %s sut)" "take_l"
| Take_r -> Format.asprintf "protect (fun () -> %s sut)" "take_r"
| Take_opt_l -> Format.asprintf "%s sut" "take_opt_l"
| Take_opt_r -> Format.asprintf "%s sut" "take_opt_r"
type nonrec state = {
Expand Down Expand Up @@ -337,7 +337,7 @@ let ortac_postcond cmd__005_ state__006_ res__007_ =
else
Some
(Ortac_runtime.report "Lwt_dllist_spec" "create ()"
(Some (Res (Ortac_runtime.dummy, ()))) "is_empty"
(Either.right (Res (Ortac_runtime.dummy, ()))) "is_empty"
[("b <-> s.contents = Sequence.empty",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -386,7 +386,7 @@ let ortac_postcond cmd__005_ state__006_ res__007_ =
else
Some
(Ortac_runtime.report "Lwt_dllist_spec" "create ()"
(Some (Res (Ortac_runtime.dummy, ()))) "length"
(Either.right (Res (Ortac_runtime.dummy, ()))) "length"
[("l = Sequence.length s.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -444,7 +444,7 @@ let ortac_postcond cmd__005_ state__006_ res__007_ =
else
Some
(Ortac_runtime.report "Lwt_dllist_spec" "create ()"
(Some (Res (Ortac_runtime.dummy, ()))) "take_l"
(Either.right (Res (Ortac_runtime.dummy, ()))) "take_l"
[("if old s.contents = Sequence.empty\n then false\n else a = Sequence.hd (old s.contents)",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -496,8 +496,8 @@ let ortac_postcond cmd__005_ state__006_ res__007_ =
then None
else
Some
(Ortac_runtime.report "Lwt_dllist_spec" "create ()" None
"take_l"
(Ortac_runtime.report "Lwt_dllist_spec" "create ()"
(Either.left "Empty") "take_l"
[("old s.contents = Sequence.empty = s.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -558,7 +558,7 @@ let ortac_postcond cmd__005_ state__006_ res__007_ =
else
Some
(Ortac_runtime.report "Lwt_dllist_spec" "create ()"
(Some (Res (Ortac_runtime.dummy, ()))) "take_r"
(Either.right (Res (Ortac_runtime.dummy, ()))) "take_r"
[("if old s.contents = Sequence.empty\n then false\n else a = (old s.contents)[Sequence.length (old s.contents) - 1]",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -610,8 +610,8 @@ let ortac_postcond cmd__005_ state__006_ res__007_ =
then None
else
Some
(Ortac_runtime.report "Lwt_dllist_spec" "create ()" None
"take_r"
(Ortac_runtime.report "Lwt_dllist_spec" "create ()"
(Either.left "Empty") "take_r"
[("old s.contents = Sequence.empty = s.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -664,7 +664,7 @@ let ortac_postcond cmd__005_ state__006_ res__007_ =
else
Some
(Ortac_runtime.report "Lwt_dllist_spec" "create ()"
(Some (Res (Ortac_runtime.dummy, ()))) "take_opt_l"
(Either.right (Res (Ortac_runtime.dummy, ()))) "take_opt_l"
[("old s.contents = match o with\n | None -> Sequence.empty\n | Some a -> Sequence.cons a s.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -716,7 +716,7 @@ let ortac_postcond cmd__005_ state__006_ res__007_ =
else
Some
(Ortac_runtime.report "Lwt_dllist_spec" "create ()"
(Some (Res (Ortac_runtime.dummy, ()))) "take_opt_r"
(Either.right (Res (Ortac_runtime.dummy, ()))) "take_opt_r"
[("old s.contents = match o with\n | None -> Sequence.empty\n | Some a -> Sequence.snoc s.contents a",
{
Ortac_runtime.start =
Expand Down
84 changes: 51 additions & 33 deletions examples/varray_circular_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -82,29 +82,33 @@ module Spec =
| Push_back x ->
Format.asprintf "%s sut %a" "push_back"
(Util.Pp.pp_elt Util.Pp.pp_char true) x
| Pop_back -> Format.asprintf "%s sut" "pop_back"
| Pop_back -> Format.asprintf "protect (fun () -> %s sut)" "pop_back"
| Push_front x_1 ->
Format.asprintf "%s sut %a" "push_front"
(Util.Pp.pp_elt Util.Pp.pp_char true) x_1
| Pop_front -> Format.asprintf "%s sut" "pop_front"
| Pop_front -> Format.asprintf "protect (fun () -> %s sut)" "pop_front"
| Insert_at (i_1, x_2) ->
Format.asprintf "%s sut %a %a" "insert_at" (Util.Pp.pp_int true)
i_1 (Util.Pp.pp_elt Util.Pp.pp_char true) x_2
Format.asprintf "protect (fun () -> %s sut %a %a)" "insert_at"
(Util.Pp.pp_int true) i_1 (Util.Pp.pp_elt Util.Pp.pp_char true)
x_2
| Pop_at i_2 ->
Format.asprintf "%s sut %a" "pop_at" (Util.Pp.pp_int true) i_2
Format.asprintf "protect (fun () -> %s sut %a)" "pop_at"
(Util.Pp.pp_int true) i_2
| Delete_at i_3 ->
Format.asprintf "%s sut %a" "delete_at" (Util.Pp.pp_int true) i_3
Format.asprintf "protect (fun () -> %s sut %a)" "delete_at"
(Util.Pp.pp_int true) i_3
| Get i_4 ->
Format.asprintf "%s sut %a" "get" (Util.Pp.pp_int true) i_4
Format.asprintf "protect (fun () -> %s sut %a)" "get"
(Util.Pp.pp_int true) i_4
| Set (i_5, v) ->
Format.asprintf "%s sut %a %a" "set" (Util.Pp.pp_int true) i_5
(Util.Pp.pp_elt Util.Pp.pp_char true) v
Format.asprintf "protect (fun () -> %s sut %a %a)" "set"
(Util.Pp.pp_int true) i_5 (Util.Pp.pp_elt Util.Pp.pp_char true) v
| Length -> Format.asprintf "%s sut" "length"
| Is_empty -> Format.asprintf "%s sut" "is_empty"
| Fill (pos, len, x_3) ->
Format.asprintf "%s sut %a %a %a" "fill" (Util.Pp.pp_int true) pos
(Util.Pp.pp_int true) len (Util.Pp.pp_elt Util.Pp.pp_char true)
x_3
Format.asprintf "protect (fun () -> %s sut %a %a %a)" "fill"
(Util.Pp.pp_int true) pos (Util.Pp.pp_int true) len
(Util.Pp.pp_elt Util.Pp.pp_char true) x_3
type nonrec state = {
contents: char Ortac_runtime.Gospelstdlib.sequence }
let init_state =
Expand Down Expand Up @@ -759,7 +763,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
else
Some
(Ortac_runtime.report "Varray_circular_spec" "make 42 'a'"
(Some (Res (Ortac_runtime.dummy, ()))) "pop_back"
(Either.right (Res (Ortac_runtime.dummy, ())))
"pop_back"
[("if old t.contents = Sequence.empty\n then false\n else proj x = (old t.contents)[Sequence.length (old t.contents) - 1]",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -812,7 +817,7 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
else
Some
(Ortac_runtime.report "Varray_circular_spec" "make 42 'a'"
None "pop_back"
(Either.left "Not_found") "pop_back"
[("t.contents = old t.contents = Sequence.empty",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -870,7 +875,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
else
Some
(Ortac_runtime.report "Varray_circular_spec" "make 42 'a'"
(Some (Res (Ortac_runtime.dummy, ()))) "pop_front"
(Either.right (Res (Ortac_runtime.dummy, ())))
"pop_front"
[("if old t.contents = Sequence.empty\n then false\n else proj x = Sequence.hd (old t.contents)",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -923,7 +929,7 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
else
Some
(Ortac_runtime.report "Varray_circular_spec" "make 42 'a'"
None "pop_front"
(Either.left "Not_found") "pop_front"
[("t.contents = old t.contents = Sequence.empty",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -980,7 +986,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
else
Some
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "insert_at"
"make 42 'a'" (Either.left "Invalid_argument")
"insert_at"
[("0 <= i <= Sequence.length t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1043,7 +1050,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
else
Some
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "insert_at"
"make 42 'a'" (Either.left "Invalid_argument")
"insert_at"
[("0 <= i <= Sequence.length t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1092,7 +1100,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
else
Some
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "pop_at"
"make 42 'a'" (Either.left "Invalid_argument")
"pop_at"
[("inside i t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1148,7 +1157,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
Some
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'"
(Some (Res (Ortac_runtime.dummy, ()))) "pop_at"
(Either.right (Res (Ortac_runtime.dummy, ())))
"pop_at"
[("(proj x) = old t.contents[i]",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1204,7 +1214,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
else
Some
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "pop_at"
"make 42 'a'" (Either.left "Invalid_argument")
"pop_at"
[("inside i t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1253,7 +1264,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
else
Some
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "delete_at"
"make 42 'a'" (Either.left "Invalid_argument")
"delete_at"
[("inside i t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1311,7 +1323,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
else
Some
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" (Some (Res (unit, ()))) "delete_at"
"make 42 'a'" (Either.right (Res (unit, ())))
"delete_at"
[("Sequence.length t.contents = Sequence.length (old t.contents) - 1",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1367,7 +1380,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
else
Some
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "delete_at"
"make 42 'a'" (Either.left "Invalid_argument")
"delete_at"
[("inside i t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1416,7 +1430,7 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
else
Some
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "get"
"make 42 'a'" (Either.left "Invalid_argument") "get"
[("inside i t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1472,7 +1486,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
Some
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'"
(Some (Res (Ortac_runtime.dummy, ()))) "get"
(Either.right (Res (Ortac_runtime.dummy, ())))
"get"
[("(proj x) = t.contents[i]",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1528,7 +1543,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
else
Some
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "get"
"make 42 'a'" (Either.left "Invalid_argument")
"get"
[("inside i t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1577,7 +1593,7 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
else
Some
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "set"
"make 42 'a'" (Either.left "Invalid_argument") "set"
[("inside i t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1634,7 +1650,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
else
Some
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "set"
"make 42 'a'" (Either.left "Invalid_argument")
"set"
[("inside i t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1683,7 +1700,7 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
else
Some
(Ortac_runtime.report "Varray_circular_spec" "make 42 'a'"
(Some (Res (Ortac_runtime.dummy, ()))) "length"
(Either.right (Res (Ortac_runtime.dummy, ()))) "length"
[("l = Sequence.length t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1732,7 +1749,7 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
else
Some
(Ortac_runtime.report "Varray_circular_spec" "make 42 'a'"
(Some (Res (Ortac_runtime.dummy, ()))) "is_empty"
(Either.right (Res (Ortac_runtime.dummy, ()))) "is_empty"
[("b <-> t.contents = Sequence.empty",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1796,7 +1813,7 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
else
Some
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "fill"
"make 42 'a'" (Either.left "Invalid_argument") "fill"
[("0 <= pos /\\ 0 <= len /\\ pos + len < Sequence.length t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1869,7 +1886,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
else
Some
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "fill"
"make 42 'a'" (Either.left "Invalid_argument")
"fill"
[("0 <= pos /\\ 0 <= len /\\ pos + len < Sequence.length t.contents",
{
Ortac_runtime.start =
Expand Down
Loading
Loading