From aef64e95442bc793eaa41c3ebc9da77e535224a6 Mon Sep 17 00:00:00 2001 From: Alexander Bandukwala <7h3kk1d@gmail.com> Date: Thu, 24 Oct 2024 14:29:06 -0400 Subject: [PATCH] Add test for parsing named function and additional parser tests --- test/Test_Menhir.re | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/Test_Menhir.re b/test/Test_Menhir.re index 12f3846b7a..5e6c516c6d 100644 --- a/test/Test_Menhir.re +++ b/test/Test_Menhir.re @@ -15,7 +15,8 @@ let alco_check = exp_typ |> Alcotest.check; // Existing recovering parser let make_term_parse = (s: string) => MakeTerm.from_zip_for_sem(Option.get(Printer.zipper_of_string(s))).term; - + +// TODO Assert against result instead of exception for parse failure for better error messages let parser_test = (name: string, exp: Term.Exp.t, actual: string) => test_case( name, @@ -175,6 +176,21 @@ let tests = [ |> Exp.fresh, "-1 + 2 - 3 / 4 * 5 ** 6 < 8" // TODO Add the remaining operators ), + parser_test( + "Let binding with type ascription", + Let( + Cast( + Var("x") |> Pat.fresh, + Int |> Typ.fresh, + Unknown(Internal) |> Typ.fresh, + ) + |> Pat.fresh, + Int(5) |> Exp.fresh, + Var("x") |> Exp.fresh, + ) + |> Exp.fresh, + "let (x : Int) = 5 in x", + ), test_case("named_function", `Quick, () => { alco_check( "named_function matches expected type",