mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-22 00:09:33 +03:00
Add some solving tests for optional fields
This commit is contained in:
parent
98a8bb8115
commit
1bdfe578bd
@ -2582,6 +2582,23 @@ mod solve_expr {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn open_optional_field_unifies_with_missing() {
|
||||
infer_eq_without_problem(
|
||||
indoc!(
|
||||
r#"
|
||||
negatePoint : { x : Int, y : Int, z ? Num c }r -> { x : Int, y : Int, z : Num c }r
|
||||
|
||||
a = negatePoint { x: 1, y: 2 }
|
||||
b = negatePoint { x: 1, y: 2, blah : "hi" }
|
||||
|
||||
{ a, b }
|
||||
"#
|
||||
),
|
||||
"{ a : { x : Int, y : Int, z : Num c }, b : { blah : Str, x : Int, y : Int, z : Num c } }",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn optional_field_unifies_with_present() {
|
||||
infer_eq_without_problem(
|
||||
@ -2595,4 +2612,21 @@ mod solve_expr {
|
||||
"{ x : Num a, y : Float, z : Int }",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn open_optional_field_unifies_with_present() {
|
||||
infer_eq_without_problem(
|
||||
indoc!(
|
||||
r#"
|
||||
negatePoint : { x : Num a, y : Num b, z ? c }r -> { x : Num a, y : Num b, z : c }r
|
||||
|
||||
a = negatePoint { x: 1, y: 2.1 }
|
||||
b = negatePoint { x: 1, y: 2.1, blah : "hi" }
|
||||
|
||||
{ a, b }
|
||||
"#
|
||||
),
|
||||
"{ a : { x : Num a, y : Float, z : c }, b : { blah : Str, x : Num a, y : Float, z : c } }",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user