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 19, 2025
1 parent 9b6dc4b commit 9797920
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,6 +378,12 @@ 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),
test_case("Negative integer literal", `Quick, () =>
evaluation_test(
"-8",
Expand Down

0 comments on commit 9797920

Please sign in to comment.