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

Print runnable scenario in case of test failure #204

Merged
merged 6 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
@@ -1,7 +1,8 @@
# Unreleased

- Improve test-failure message
[\#202](https://github.com/ocaml-gospel/ortac/pull/202)
[\#202](https://github.com/ocaml-gospel/ortac/pull/202) and
[\#204](https://github.com/ocaml-gospel/ortac/pull/204)
- 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
40 changes: 24 additions & 16 deletions examples/lwt_dllist_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ module Spec =
| Take_opt_r
let show_cmd cmd__001_ =
match cmd__001_ with
| Is_empty -> Format.asprintf "%s" "is_empty"
| Length -> Format.asprintf "%s" "length"
| Is_empty -> Format.asprintf "%s sut" "is_empty"
| Length -> Format.asprintf "%s sut" "length"
| Add_l a_1 ->
Format.asprintf "%s %a" "add_l" (Util.Pp.pp_int true) a_1
Format.asprintf "%s %a sut" "add_l" (Util.Pp.pp_int true) a_1
| Add_r a_2 ->
Format.asprintf "%s %a" "add_r" (Util.Pp.pp_int true) a_2
| Take_l -> Format.asprintf "%s" "take_l"
| Take_r -> Format.asprintf "%s" "take_r"
| Take_opt_l -> Format.asprintf "%s" "take_opt_l"
| Take_opt_r -> Format.asprintf "%s" "take_opt_r"
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_opt_l -> Format.asprintf "%s sut" "take_opt_l"
| Take_opt_r -> Format.asprintf "%s sut" "take_opt_r"
type nonrec state = {
contents: int Ortac_runtime.Gospelstdlib.sequence }
let init_state =
Expand Down Expand Up @@ -336,7 +336,8 @@ let ortac_postcond cmd__005_ state__006_ res__007_ =
then None
else
Some
(Ortac_runtime.report "is_empty"
(Ortac_runtime.report "Lwt_dllist_spec" "create ()"
(Some (Res (Ortac_runtime.dummy, ()))) "is_empty"
[("b <-> s.contents = Sequence.empty",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -384,7 +385,8 @@ let ortac_postcond cmd__005_ state__006_ res__007_ =
then None
else
Some
(Ortac_runtime.report "length"
(Ortac_runtime.report "Lwt_dllist_spec" "create ()"
(Some (Res (Ortac_runtime.dummy, ()))) "length"
[("l = Sequence.length s.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -441,7 +443,8 @@ let ortac_postcond cmd__005_ state__006_ res__007_ =
then None
else
Some
(Ortac_runtime.report "take_l"
(Ortac_runtime.report "Lwt_dllist_spec" "create ()"
(Some (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 @@ -493,7 +496,8 @@ let ortac_postcond cmd__005_ state__006_ res__007_ =
then None
else
Some
(Ortac_runtime.report "take_l"
(Ortac_runtime.report "Lwt_dllist_spec" "create ()" None
"take_l"
[("old s.contents = Sequence.empty = s.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -553,7 +557,8 @@ let ortac_postcond cmd__005_ state__006_ res__007_ =
then None
else
Some
(Ortac_runtime.report "take_r"
(Ortac_runtime.report "Lwt_dllist_spec" "create ()"
(Some (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 @@ -605,7 +610,8 @@ let ortac_postcond cmd__005_ state__006_ res__007_ =
then None
else
Some
(Ortac_runtime.report "take_r"
(Ortac_runtime.report "Lwt_dllist_spec" "create ()" None
"take_r"
[("old s.contents = Sequence.empty = s.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -657,7 +663,8 @@ let ortac_postcond cmd__005_ state__006_ res__007_ =
then None
else
Some
(Ortac_runtime.report "take_opt_l"
(Ortac_runtime.report "Lwt_dllist_spec" "create ()"
(Some (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 @@ -708,7 +715,8 @@ let ortac_postcond cmd__005_ state__006_ res__007_ =
then None
else
Some
(Ortac_runtime.report "take_opt_r"
(Ortac_runtime.report "Lwt_dllist_spec" "create ()"
(Some (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
92 changes: 58 additions & 34 deletions examples/varray_circular_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,29 @@ module Spec =
let show_cmd cmd__003_ =
match cmd__003_ with
| Push_back x ->
Format.asprintf "%s %a" "push_back"
Format.asprintf "%s sut %a" "push_back"
(Util.Pp.pp_elt Util.Pp.pp_char true) x
| Pop_back -> Format.asprintf "%s" "pop_back"
| Pop_back -> Format.asprintf "%s sut" "pop_back"
| Push_front x_1 ->
Format.asprintf "%s %a" "push_front"
Format.asprintf "%s sut %a" "push_front"
(Util.Pp.pp_elt Util.Pp.pp_char true) x_1
| Pop_front -> Format.asprintf "%s" "pop_front"
| Pop_front -> Format.asprintf "%s sut" "pop_front"
| Insert_at (i_1, x_2) ->
Format.asprintf "%s %a %a" "insert_at" (Util.Pp.pp_int true) i_1
(Util.Pp.pp_elt Util.Pp.pp_char true) 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
| Pop_at i_2 ->
Format.asprintf "%s %a" "pop_at" (Util.Pp.pp_int true) i_2
Format.asprintf "%s sut %a" "pop_at" (Util.Pp.pp_int true) i_2
| Delete_at i_3 ->
Format.asprintf "%s %a" "delete_at" (Util.Pp.pp_int true) i_3
| Get i_4 -> Format.asprintf "%s %a" "get" (Util.Pp.pp_int true) i_4
Format.asprintf "%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
| Set (i_5, v) ->
Format.asprintf "%s %a %a" "set" (Util.Pp.pp_int true) i_5
Format.asprintf "%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" "length"
| Is_empty -> Format.asprintf "%s" "is_empty"
| Length -> Format.asprintf "%s sut" "length"
| Is_empty -> Format.asprintf "%s sut" "is_empty"
| Fill (pos, len, x_3) ->
Format.asprintf "%s %a %a %a" "fill" (Util.Pp.pp_int true) pos
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
type nonrec state = {
Expand Down Expand Up @@ -757,7 +758,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
then None
else
Some
(Ortac_runtime.report "pop_back"
(Ortac_runtime.report "Varray_circular_spec" "make 42 'a'"
(Some (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 @@ -809,7 +811,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
then None
else
Some
(Ortac_runtime.report "pop_back"
(Ortac_runtime.report "Varray_circular_spec" "make 42 'a'"
None "pop_back"
[("t.contents = old t.contents = Sequence.empty",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -866,7 +869,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
then None
else
Some
(Ortac_runtime.report "pop_front"
(Ortac_runtime.report "Varray_circular_spec" "make 42 'a'"
(Some (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 @@ -918,7 +922,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
then None
else
Some
(Ortac_runtime.report "pop_front"
(Ortac_runtime.report "Varray_circular_spec" "make 42 'a'"
None "pop_front"
[("t.contents = old t.contents = Sequence.empty",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -974,7 +979,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
then None
else
Some
(Ortac_runtime.report "insert_at"
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "insert_at"
[("0 <= i <= Sequence.length t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1036,7 +1042,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
then None
else
Some
(Ortac_runtime.report "insert_at"
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "insert_at"
[("0 <= i <= Sequence.length t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1084,7 +1091,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
then None
else
Some
(Ortac_runtime.report "pop_at"
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "pop_at"
[("inside i t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1138,7 +1146,9 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
then None
else
Some
(Ortac_runtime.report "pop_at"
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'"
(Some (Res (Ortac_runtime.dummy, ()))) "pop_at"
[("(proj x) = old t.contents[i]",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1193,7 +1203,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
then None
else
Some
(Ortac_runtime.report "pop_at"
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "pop_at"
[("inside i t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1241,7 +1252,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
then None
else
Some
(Ortac_runtime.report "delete_at"
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "delete_at"
[("inside i t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1298,7 +1310,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
then None
else
Some
(Ortac_runtime.report "delete_at"
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" (Some (Res (unit, ()))) "delete_at"
[("Sequence.length t.contents = Sequence.length (old t.contents) - 1",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1353,7 +1366,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
then None
else
Some
(Ortac_runtime.report "delete_at"
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "delete_at"
[("inside i t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1401,7 +1415,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
then None
else
Some
(Ortac_runtime.report "get"
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "get"
[("inside i t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1455,7 +1470,9 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
then None
else
Some
(Ortac_runtime.report "get"
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'"
(Some (Res (Ortac_runtime.dummy, ()))) "get"
[("(proj x) = t.contents[i]",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1510,7 +1527,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
then None
else
Some
(Ortac_runtime.report "get"
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "get"
[("inside i t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1558,7 +1576,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
then None
else
Some
(Ortac_runtime.report "set"
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "set"
[("inside i t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1614,7 +1633,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
then None
else
Some
(Ortac_runtime.report "set"
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "set"
[("inside i t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1662,7 +1682,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
then None
else
Some
(Ortac_runtime.report "length"
(Ortac_runtime.report "Varray_circular_spec" "make 42 'a'"
(Some (Res (Ortac_runtime.dummy, ()))) "length"
[("l = Sequence.length t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1710,7 +1731,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
then None
else
Some
(Ortac_runtime.report "is_empty"
(Ortac_runtime.report "Varray_circular_spec" "make 42 'a'"
(Some (Res (Ortac_runtime.dummy, ()))) "is_empty"
[("b <-> t.contents = Sequence.empty",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1773,7 +1795,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
then None
else
Some
(Ortac_runtime.report "fill"
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "fill"
[("0 <= pos /\\ 0 <= len /\\ pos + len < Sequence.length t.contents",
{
Ortac_runtime.start =
Expand Down Expand Up @@ -1845,7 +1868,8 @@ let ortac_postcond cmd__016_ state__017_ res__018_ =
then None
else
Some
(Ortac_runtime.report "fill"
(Ortac_runtime.report "Varray_circular_spec"
"make 42 'a'" None "fill"
[("0 <= pos /\\ 0 <= len /\\ pos + len < Sequence.length t.contents",
{
Ortac_runtime.start =
Expand Down
Loading
Loading