Skip to content

Commit

Permalink
Add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Negabinary committed Feb 17, 2025
1 parent 4e2bff3 commit a8fb5bf
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions test/Test_Evaluator.re
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,44 @@ let test_unevaluated_if = () =>
|> Exp.fresh,
);

let test_invalid_constructor_match = () => {
let invalid_constructor_match =
Let(
Constructor("T", Unknown(Internal) |> Typ.fresh) |> Pat.fresh,
Int(1) |> Exp.fresh,
EmptyHole |> Exp.fresh,
)
|> Exp.fresh
|> elaborate;
evaluation_test(
"let T = 1 in ?",
invalid_constructor_match,
invalid_constructor_match,
);
};

let test_typfun_application = () =>
evaluation_test(
"(typfun T -> fun x -> 1)@<Int>(2)",
Int(1) |> Exp.fresh,
Ap(
Forward,
TypAp(
TypFun(
Var("T") |> TPat.fresh,
Fun(Var("x") |> Pat.fresh, Int(1) |> Exp.fresh, None, None)
|> Exp.fresh,
None,
)
|> Exp.fresh,
Int |> Typ.fresh,
)
|> Exp.fresh,
Int(2) |> Exp.fresh,
)
|> Exp.fresh,
);

let tests = (
"Evaluator",
[
Expand Down Expand Up @@ -340,5 +378,11 @@ in fn("hello")|},
test_case("Variable capture", `Quick, test_variable_capture),
test_case("Unbound lookup", `Quick, test_unbound_lookup),
test_case("Unevaluated if closure", `Quick, test_unevaluated_if),
test_case(
"Invalid constructor match",
`Quick,
test_invalid_constructor_match,
),
test_case("Typfun application", `Quick, test_typfun_application),
],
);

0 comments on commit a8fb5bf

Please sign in to comment.