Skip to content

Commit

Permalink
Add test for parsing named function and additional parser tests
Browse files Browse the repository at this point in the history
  • Loading branch information
7h3kk1d committed Oct 24, 2024
1 parent 9a3b5dd commit aef64e9
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion test/Test_Menhir.re
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit aef64e9

Please sign in to comment.