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

Improve failure message in case of out of domain failure #287

Merged
merged 5 commits into from
Mar 3, 2025

Conversation

n-osborne
Copy link
Collaborator

This PR proposes to improve the failure message in case of out of domain failure.

Gospel supports partial function, but OCaml doesn't. The translation from Gospel to OCaml used in Ortac/QCheck-STM interprets an out of domain call to a partial function as raising the Ortac_runtime.Partial_function.

This is captured by QCheck as a test failure (which makes perfect sense), but the ortac runtime is stopped before being able to pass a full report to QCheck.

In order to keep the benefit of the report built by ortac, the PR proposes to:

  • interpret Ortac_runtime.Partial_function as false in post and pre conditions
  • capture the Ortac_runtime.Partial_function piece of information in a new Out_of_domain constructor for expected_value when computing the expected returned value for the report (the report won't include an expected returned value, as there is none, but the user will have access to the runnable scenario)

This allows to always enjoy a full Ortac/QCheck-STM report in case of test failure involving the evaluation of a Gospel partial function.

This translation interprets out of domain call to partial functions as
false when the returned type is either bool or prop.
A new `Out_of_domain` constructor is added in the runtime representation
of expected values to encode the information.
@n-osborne n-osborne merged commit e333557 into ocaml-gospel:main Mar 3, 2025
3 checks passed
n-osborne added a commit to n-osborne/opam-repository that referenced this pull request Mar 5, 2025
This new release comes with three improvements:

- Make search for returned value description more flexible
  [\ocaml#291](ocaml-gospel/ortac#291)
- Fix generation of the `QCheck.Fn.apply` identifier
  [\ocaml#288](ocaml-gospel/ortac#288)
- Improve failure message in case of out of domain failure
  [\ocaml#287](ocaml-gospel/ortac#287)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant