Skip to content

Commit

Permalink
Add parser tests for singleton tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
7h3kk1d committed Oct 11, 2024
1 parent c8ef191 commit 22cd8d6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/Test_Elaboration.re
Original file line number Diff line number Diff line change
Expand Up @@ -418,5 +418,6 @@ let elaboration_tests = [
`Quick,
singleton_labeled_tuple_elaborates_labels,
),
test_case("Singleton labeled tuple", `Quick, singleton_labeled_tuple),
test_case("Singleton labeled tuple", `Quick, singleton_labeled_tuple) // TODO Make consistent with make term
// TODO Add singleton labeled function application
];
37 changes: 37 additions & 0 deletions test/Test_MakeTerm.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* This file contains tests to validate the `MakeTerm` module's ability to convert
* zippers into expressions.
*/
open Alcotest;
open Haz3lcore;

let exp_typ = testable(Fmt.using(Exp.show, Fmt.string), Exp.fast_equal);

// TODO Assertion if it doesn't parse
let parse_exp = (s: string) =>
MakeTerm.from_zip_for_sem(Option.get(Printer.zipper_of_string(s))).term;
let exp_check = (expected, actual) =>
check(exp_typ, actual, expected, parse_exp(actual));

let tests = [
test_case("Singleton Labled Tuple ascription in let", `Quick, () => {
exp_check(
Let(
Cast(
Var("x") |> Pat.fresh,
Parens(
TupLabel(Label("l") |> Typ.fresh, String |> Typ.fresh) // TODO Do we want to wrap the singleton case in a product
|> Typ.fresh,
)
|> Typ.fresh,
Unknown(Internal) |> Typ.fresh,
)
|> Pat.fresh,
Parens(String("a") |> Exp.fresh) |> Exp.fresh, // TODO Should we require parens around singleton tables to ascribe labels
Var("x") |> Exp.fresh,
)
|> Exp.fresh,
"let x : (l=String) = \"a\" in x",
)
}),
];
1 change: 1 addition & 0 deletions test/haz3ltest.re
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ let (suite, _) =
("LabeledTuple", Test_LabeledTuple.tests),
("Statics", Test_Statics.tests),
("Evaluator", Test_Evaluator.tests),
("MakeTerm", Test_MakeTerm.tests),
],
);
Junit.to_file(Junit.make([suite]), "junit_tests.xml");

0 comments on commit 22cd8d6

Please sign in to comment.