From 24810ca77865828334cbf7ecad7b702f34319844 Mon Sep 17 00:00:00 2001 From: Ayaz Hafiz Date: Wed, 3 Aug 2022 16:19:50 -0500 Subject: [PATCH] Add a couple tests that currently hit a compiler panic --- crates/compiler/test_gen/src/gen_abilities.rs | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/crates/compiler/test_gen/src/gen_abilities.rs b/crates/compiler/test_gen/src/gen_abilities.rs index bf194ac5c1..f4808300ec 100644 --- a/crates/compiler/test_gen/src/gen_abilities.rs +++ b/crates/compiler/test_gen/src/gen_abilities.rs @@ -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 + _ -> "" + "# + ), + 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 + ) +}