Add a couple tests that currently hit a compiler panic

This commit is contained in:
Ayaz Hafiz 2022-08-03 16:19:50 -05:00
parent 1273a6ab0b
commit 24810ca778
No known key found for this signature in database
GPG Key ID: 0E2A37416A25EF58

View File

@ -689,6 +689,31 @@ fn encode_derived_list_of_records() {
)
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[ignore = "Currently hits some weird panic in borrow checking, not sure if it's directly related to abilities."]
fn encode_derived_list_of_lists_of_strings() {
assert_evals_to!(
indoc!(
r#"
app "test"
imports [Encode.{ toEncoder }, Json]
provides [main] to "./platform"
main =
lst = [["a", "b"], ["c", "d", "e"], ["f"]]
encoded = Encode.toBytes lst Json.toUtf8
result = Str.fromUtf8 encoded
when result is
Ok s -> s
_ -> "<bad>"
"#
),
RocStr::from(r#"[["a","b"],["c","d","e"],["f"]]"#),
RocStr
)
}
#[test]
#[cfg(all(
any(feature = "gen-llvm", feature = "gen-wasm"),
@ -910,3 +935,23 @@ fn encode_then_decode_list_of_strings() {
RocStr
)
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
#[ignore = "Currently hits some weird panic in borrow checking, not sure if it's directly related to abilities."]
fn encode_then_decode_list_of_lists_of_strings() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Encode, Decode, Json] provides [main] to "./platform"
main =
when Encode.toBytes [["a", "b"], ["c", "d", "e"], ["f"]] Json.fromUtf8 |> Decode.fromBytes Json.fromUtf8 is
Ok list -> (List.map list \inner -> Str.joinWith inner ",") |> Str.joinWith l ";"
_ -> "something went wrong"
"#
),
RocStr::from("a,b;c,d,e;f"),
RocStr
)
}