Skip to content

Commit

Permalink
Add test for multiple attributes on a binder
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszbujalski committed Feb 12, 2021
1 parent a1348cd commit 97a9429
Show file tree
Hide file tree
Showing 6 changed files with 375 additions and 31 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Expand Up @@ -147,6 +147,10 @@ Guidelines for the changelog:
a semicolon separated list of terms. The old syntax will soon
be deprecated.

* Attributes on binders are now using a different syntax `[@@@ a1; ... ; an]` i.e.,
@@@ instead of @@. This is a breaking change that enables
using attributes on explicit binders, record fields and more. See
https://github.com/FStarLang/FStar/pull/2192 for more details.

## Extraction

Expand Down
28 changes: 10 additions & 18 deletions tests/micro-benchmarks/BinderAttributes.fst
@@ -1,6 +1,7 @@
module BinderAttributes

module T = FStar.Tactics
open FStar.List.Tot

let default_to (def : 'a) (x : option 'a) : Tot 'a =
match x with
Expand Down Expand Up @@ -105,46 +106,37 @@ let rec validate (expected : binders) (actual : binders) : T.Tac unit =
end
| _, _ -> T.fail "Test failed. Expected different number of binders"

let rec iter2 (f : 'a -> 'b -> T.Tac unit) (l1 : list 'a) (l2 : list 'b) : T.Tac unit =
match l1, l2 with
| [], [] -> ()
| x :: xs, y :: ys -> begin
f x y;
iter2 f xs ys
end
| _, _ -> T.fail "Lists have different sizes"

let _ =
assert True by begin
T.print "inductive_example:";
let b = binders_from_term (T.top_env()) (T.explode_qn (`%inductive_example)) in
let bss = T.map (fun b -> binders_to_string b) b in
T.iter (fun bs -> T.print bs) bss;
let expected =
[
[{ name = "x"; qual = "Explicit"; desc = Some "x"; }; { name = "y"; qual = "Explicit"; desc = Some "y"; }];
[{ name = "x_imp"; qual = "Implicit"; desc = Some "x_imp"; }; { name = "y_imp"; qual = "Implicit"; desc = Some "y_imp"; }];
[{ name = "x_imp"; qual = "Implicit"; desc = Some "x_imp"; }; { name = "y"; qual = "Explicit"; desc = Some "y"; }];
] in
iter2 (fun ex bs -> validate ex bs) expected b
if length expected = length b
then T.iter2 (fun ex bs -> validate ex bs) expected b
else T.fail "Lists have different sizes"
end

let _ =
assert True by begin
T.print "f:";
let b = binders_from_term (T.top_env()) (T.explode_qn (`%f)) in
let bss = T.map (fun b -> binders_to_string b) b in
T.iter (fun bs -> T.print bs) bss;
let expected = [[{ name = "x_imp"; qual = "Implicit"; desc = Some "x_imp"; }; { name = "y"; qual = "Explicit"; desc = Some "y"; }]] in
iter2 (fun ex bs -> validate ex bs) expected b
if length expected = length b
then T.iter2 (fun ex bs -> validate ex bs) expected b
else T.fail "Lists have different sizes"
end

let _ =
assert True by begin
T.print "f2:";
let b = binders_from_term (T.top_env()) (T.explode_qn (`%f2)) in
let bss = T.map (fun b -> binders_to_string b) b in
T.iter (fun bs -> T.print bs) bss;
let expected = [[{ name = "x_imp"; qual = "Implicit"; desc = Some "x_imp"; }; { name = "y"; qual = "Explicit"; desc = Some "y"; }]] in
iter2 (fun ex bs -> validate ex bs) expected b
if length expected = length b
then T.iter2 (fun ex bs -> validate ex bs) expected b
else T.fail "Lists have different sizes"
end
161 changes: 148 additions & 13 deletions tests/micro-benchmarks/BinderAttributes.fst.hints

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 97a9429

Please sign in to comment.