implement standard as patterns in mono IR

This commit is contained in:
Folkert 2023-01-11 14:12:53 +01:00
parent 726d8d80c4
commit cf15654ee5
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
7 changed files with 347 additions and 128 deletions

View file

@ -2217,7 +2217,7 @@ fn issue_4749() {
expect
input = [82, 111, 99]
got = Decode.fromBytes input Json.fromUtf8
got = Decode.fromBytes input Json.fromUtf8
got == Ok "Roc"
"###
)
@ -2246,7 +2246,7 @@ fn lambda_set_with_imported_toplevels_issue_4733() {
fn order_list_size_tests_issue_4732() {
indoc!(
r###"
when [] is
when [] is
[1, ..] -> "B1"
[2, 1, ..] -> "B2"
[3, 2, 1, ..] -> "B3"
@ -2363,3 +2363,48 @@ fn nullable_wrapped_with_nullable_not_last_index() {
"###
)
}
#[mono_test]
fn pattern_as_toplevel() {
indoc!(
r###"
app "test" provides [main] to "./platform"
record = { a: 42i64, b: "foo" }
main =
when record is
{ a: 42i64 } as r -> record == r
_ -> Bool.false
"###
)
}
#[mono_test]
fn pattern_as_nested() {
indoc!(
r###"
app "test" provides [main] to "./platform"
record = { a: 42i64, b: "foo" }
main =
when Pair {} record is
Pair {} ({ a: 42i64 } as r) -> record == r
_ -> Bool.false
"###
)
}
#[mono_test]
fn pattern_as_of_symbol() {
indoc!(
r###"
app "test" provides [main] to "./platform"
main =
when "foo" is
a as b -> a == b
"###
)
}