-
Notifications
You must be signed in to change notification settings - Fork 124
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 unit tests via $[test]
attribute
#928
base: sail2
Are you sure you want to change the base?
Conversation
Still TODO: * Documentation * Verify the type is `unit -> unit` for functions where this is applied. * Tests * Other backends?? * Output formatting isn't quite right; not sure why.
Test Results 12 files ± 0 24 suites ±0 0s ⏱️ ±0s For more details on these errors, see this check. Results for commit 59d29e3. ± Comparison against base commit e7f1262. ♻️ This comment has been updated with latest results. |
Yes, that looks like the right way to go. |
@@ -4630,6 +4630,14 @@ let check_fundef_lazy env def_annot (FD_aux (FD_function (recopt, tannot_opt, fu | |||
| Some vs_l -> check_tannot_opt ~def_type:"function" vs_l env vtyp_ret tannot_opt | |||
| None -> () | |||
end; | |||
(* Check $[test] functions have type unit -> unit. *) | |||
(* TODO: Does the annotation go on the type declaration or the function definition? *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in general we put these annotations on the val
type declarations. That's where $[property]
and $[counterexample]
are expected to be.
If you have a function with an inline annotation:
$[annot]
function f(x : int) -> unit = ...
it'll get expanded to
$[annot]
val f : int -> unit
$[annot]
function f(x) = ...
with the annotation on both.
@@ -2225,6 +2225,7 @@ let compile_ast env effect_info output_chan c_includes ast = | |||
let end_extern_cpp = separate hardline (List.map string [""; "#ifdef __cplusplus"; "}"; "#endif"]) in | |||
let hlhl = hardline ^^ hardline in | |||
|
|||
(* TODO: Formatting here isn't quite right. What are the arguments to jump? *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's explained a bit here https://github.com/fpottier/pprint/blob/767ef4ae0d5de95b21e0d650e8bb752830d75a47/src/PPrint.mli#L163
I think this change has probably broken this PR: #960 I can fix if you like? |
Ah that's a nice change. Don't worry, I'll try and figure it out. You have more important things to do! |
Draft for #919, just checking if this approach makes sense.
Still TODO:
unit -> unit
for functions where this is applied.