From fe864a445de4c04546bbe466e6d3aaee27f92a85 Mon Sep 17 00:00:00 2001 From: Ayaz Hafiz Date: Tue, 26 Jul 2022 16:30:32 -0400 Subject: [PATCH] Add a test for big encoders enabled by disjoint specialization variables --- crates/compiler/test_gen/src/gen_abilities.rs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/crates/compiler/test_gen/src/gen_abilities.rs b/crates/compiler/test_gen/src/gen_abilities.rs index ed16447514..3aa4a0067f 100644 --- a/crates/compiler/test_gen/src/gen_abilities.rs +++ b/crates/compiler/test_gen/src/gen_abilities.rs @@ -684,3 +684,30 @@ fn encode_derived_list_of_records() { RocStr ) } + +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn encode_derived_record_with_many_types() { + assert_evals_to!( + indoc!( + r#" + app "test" + imports [Encode.{ toEncoder }, Json] + provides [main] to "./platform" + + main = + fresh : [Fresh Str, Rotten Str] + fresh = Fresh "tomatoes" + rcd = {actors: ["Idris Elba", "Mila Kunis"], year: 2004u16, rating: {average: 7u8, min: 1u8, max: 10u8, sentiment: fresh}} + result = Str.fromUtf8 (Encode.toBytes rcd Json.toUtf8) + when result is + Ok s -> s + _ -> "" + "# + ), + RocStr::from( + r#"{"actors":["Idris Elba","Mila Kunis"],"rating":{"average":7,"max":10,"min":1,"sentiment":{"Fresh":["tomatoes"]}},"year":2004}"# + ), + RocStr + ) +}