Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
7h3kk1d committed Oct 13, 2024
1 parent 78e817c commit 7008809
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 7 deletions.
45 changes: 38 additions & 7 deletions test/Test_MakeTerm.re
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,57 @@ let tests = [
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
Prod([
TupLabel(Label("l") |> Typ.fresh, String |> Typ.fresh)
|> Typ.fresh,
])
|> 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
Parens(String("a") |> Exp.fresh) |> Exp.fresh,
Var("x") |> Exp.fresh,
)
|> Exp.fresh,
"let x : (l=String) = \"a\" in x",
"let x : (l=String) = (\"a\") in x",
)
}),
test_case("", `Quick, () => {
test_case("Assigning labeled tuple to variable", `Quick, () => {
exp_check(
Int(7) |> Exp.fresh,
Let(
Var("x") |> Pat.fresh,
Parens(
Tuple([
TupLabel(Label("l") |> Exp.fresh, Int(32) |> Exp.fresh)
|> Exp.fresh,
])
|> Exp.fresh,
)
|> Exp.fresh,
Let(
Cast(
Var("y") |> Pat.fresh,
Parens(
Prod([
TupLabel(Label("l") |> Typ.fresh, Int |> Typ.fresh)
|> Typ.fresh,
])
|> Typ.fresh,
)
|> Typ.fresh,
Unknown(Internal) |> Typ.fresh,
)
|> Pat.fresh,
Var("x") |> Exp.fresh,
Var("y") |> Exp.fresh,
)
|> Exp.fresh,
)
|> Exp.fresh,
"let x = (l=32) in
let y : (l=Int) = x in
",
let y : (l=Int) = x in y",
)
}),
];
76 changes: 76 additions & 0 deletions test/Test_Statics.re
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,80 @@ let tests =
),
unlabeled_tuple_to_labeled_fails,
simple_inconsistency,
test_case("Assigning labeled tuple to variable", `Quick, () => {
alco_check(
"let x = (l=32) in
let y : (l=Int) = x in y",
Some(
Prod([
TupLabel(Label("l") |> Typ.fresh, Int |> Typ.fresh) |> Typ.fresh,
])
|> Typ.fresh,
),
type_of(
Let(
Var("x") |> Pat.fresh,
Parens(
Tuple([
TupLabel(Label("l") |> Exp.fresh, Int(32) |> Exp.fresh)
|> Exp.fresh,
])
|> Exp.fresh,
)
|> Exp.fresh,
Let(
Cast(
Var("y") |> Pat.fresh,
Parens(
Prod([
TupLabel(Label("l") |> Typ.fresh, Int |> Typ.fresh)
|> Typ.fresh,
])
|> Typ.fresh,
)
|> Typ.fresh,
Unknown(Internal) |> Typ.fresh,
)
|> Pat.fresh,
Var("x") |> Exp.fresh,
Var("y") |> Exp.fresh,
)
|> Exp.fresh,
)
|> Exp.fresh,
),
)
}),
test_case("Singleton Labled Tuple ascription in let", `Quick, () => {
alco_check(
"let x : (l=String) = (\"a\") in x",
Some(
Prod([
TupLabel(Label("l") |> Typ.fresh, String |> Typ.fresh)
|> Typ.fresh,
])
|> Typ.fresh,
),
type_of(
Let(
Cast(
Var("x") |> Pat.fresh,
Parens(
Prod([
TupLabel(Label("l") |> Typ.fresh, String |> Typ.fresh)
|> Typ.fresh,
])
|> Typ.fresh,
)
|> Typ.fresh,
Unknown(Internal) |> Typ.fresh,
)
|> Pat.fresh,
Parens(String("a") |> Exp.fresh) |> Exp.fresh, // TODO Need to assert there's no inconsistency in this branch
Var("x") |> Exp.fresh,
)
|> Exp.fresh,
),
)
}),
];

0 comments on commit 7008809

Please sign in to comment.