Migrate more tests

This commit is contained in:
Ayaz Hafiz 2023-04-12 18:08:05 -05:00
parent 9775d4f0ca
commit 7c14b78e5d
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
14 changed files with 137 additions and 215 deletions

View file

@ -6109,219 +6109,4 @@ mod solve_expr {
"Str",
)
}
#[test]
fn self_recursion_with_inference_var() {
infer_eq_without_problem(
indoc!(
r#"
f : _ -> _
f = \_ -> if Bool.false then "" else f ""
f
"#
),
"Str -> Str",
)
}
#[test]
fn mutual_recursion_with_inference_var() {
infer_eq_without_problem(
indoc!(
r#"
f : _ -> Str
f = \s -> g s
g = \s -> if Bool.true then s else f s
g
"#
),
"Str -> Str",
)
}
#[test]
fn function_alias_in_signature() {
infer_eq_without_problem(
indoc!(
r#"
app "test" provides [main] to "./platform"
Parser a : List U8 -> List [Pair a (List U8)]
any: Parser U8
any = \inp ->
when List.first inp is
Ok u -> [Pair u (List.drop inp 1)]
_ -> []
main = any
"#
),
"Parser U8",
);
}
#[test]
fn infer_variables_in_value_def_signature() {
infer_eq_without_problem(
indoc!(
r#"
app "test" provides [a] to "./platform"
a : {a: _}
a = {a: ""}
"#
),
"{ a : Str }",
);
}
#[test]
fn infer_variables_in_destructure_def_signature() {
infer_eq_without_problem(
indoc!(
r#"
app "test" provides [a] to "./platform"
{a} : {a: _}
{a} = {a: ""}
"#
),
"Str",
)
}
#[test]
fn check_phantom_type() {
infer_eq_without_problem(
indoc!(
r#"
F a b := b
foo : F Str Str -> F U8 Str
x : F Str Str
foo x
"#
),
"F U8 Str",
)
}
#[test]
fn infer_phantom_type_flow() {
infer_eq_without_problem(
indoc!(
r#"
F a b := b
foo : _ -> F U8 Str
foo = \it -> it
foo
"#
),
"F U8 Str -> F U8 Str",
)
}
#[test]
fn infer_unbound_phantom_type_star() {
infer_eq_without_problem(
indoc!(
r#"
F a b := b
foo = \@F {} -> @F ""
foo
"#
),
"F * {}* -> F * Str",
)
}
#[test]
fn wrap_recursive_opaque_negative_position() {
infer_eq_without_problem(
indoc!(
r#"
OList := [Nil, Cons {} OList]
lst : [Cons {} OList]
olist : OList
olist = (\l -> @OList l) lst
olist
"#
),
"OList",
);
}
#[test]
fn wrap_recursive_opaque_positive_position() {
infer_eq_without_problem(
indoc!(
r#"
OList := [Nil, Cons {} OList]
lst : [Cons {} OList]
olist : OList
olist = @OList lst
olist
"#
),
"OList",
);
}
#[test]
fn rosetree_with_result_is_legal_recursive_type() {
infer_eq_without_problem(
indoc!(
r#"
Rose a : [Rose (Result (List (Rose a)) I64)]
x : Rose I64
x = Rose (Ok [])
x
"#
),
"Rose I64",
);
}
#[test]
fn opaque_wrap_function() {
infer_eq_without_problem(
indoc!(
r#"
A := U8
List.map [1, 2, 3] @A
"#
),
"List A",
);
}
#[test]
fn opaque_wrap_function_with_inferred_arg() {
infer_eq_without_problem(
indoc!(
r#"
A a := a
List.map [1u8, 2u8, 3u8] @A
"#
),
"List (A U8)",
);
}
}

View file

@ -0,0 +1,13 @@
app "test" provides [main] to "./platform"
entry =
F a b := b
foo : F Str Str -> F U8 Str
x : F Str Str
foo x
main = entry
# ^^^^^ F U8 Str

View file

@ -0,0 +1,12 @@
app "test" provides [main] to "./platform"
Parser a : List U8 -> List [Pair a (List U8)]
any: Parser U8
any = \inp ->
when List.first inp is
Ok u -> [Pair u (List.drop inp 1)]
_ -> []
main = any
# ^^^ Parser U8

View file

@ -0,0 +1,12 @@
app "test" provides [main] to "./platform"
entry =
F a b := b
foo : _ -> F U8 Str
foo = \it -> it
foo
main = entry
# ^^^^^ F U8 Str -[[foo(3)]]-> F U8 Str

View file

@ -0,0 +1,11 @@
app "test" provides [main] to "./platform"
entry =
F a b := b
foo = \@F {} -> @F ""
foo
main = entry
# ^^^^^ F w_a {}w_b -[[foo(3)]]-> F w_c Str

View file

@ -0,0 +1,7 @@
app "test" provides [f] to "./platform"
{a} : {a: _}
{a} = {a: ""}
f = a
# ^ Str

View file

@ -0,0 +1,5 @@
app "test" provides [a] to "./platform"
a : {a: _}
a = {a: ""}
#^{-1} { a : Str }

View file

@ -0,0 +1,11 @@
app "test" provides [main] to "./platform"
entry =
f : _ -> Str
f = \s -> g s
g = \s -> if Bool.true then s else f s
g
main = entry
# ^^^^^ Str -[[g(3)]]-> Str

View file

@ -0,0 +1,8 @@
app "test" provides [main] to "./platform"
entry =
A := U8
List.map [1, 2, 3] @A
main = entry
# ^^^^^ List A

View file

@ -0,0 +1,8 @@
app "test" provides [main] to "./platform"
entry =
A a := a
List.map [1u8, 2u8, 3u8] @A
main = entry
# ^^^^^ List (A U8)

View file

@ -0,0 +1,12 @@
app "test" provides [main] to "./platform"
entry =
Rose a : [Rose (Result (List (Rose a)) I64)]
x : Rose I64
x = Rose (Ok [])
x
main = entry
# ^^^^^ Rose I64

View file

@ -0,0 +1,10 @@
app "test" provides [main] to "./platform"
entry =
f : _ -> _
f = \_ -> if Bool.false then "" else f ""
f
main = entry
# ^^^^^ Str -[[f(2)]]-> Str

View file

@ -0,0 +1,14 @@
app "test" provides [main] to "./platform"
entry =
OList := [Nil, Cons {} OList]
lst : [Cons {} OList]
olist : OList
olist = (\l -> @OList l) lst
olist
main = entry
# ^^^^^ OList

View file

@ -0,0 +1,14 @@
app "test" provides [main] to "./platform"
entry =
OList := [Nil, Cons {} OList]
lst : [Cons {} OList]
olist : OList
olist = @OList lst
olist
main = entry
# ^^^^^ OList