Add a test for big encoders enabled by disjoint specialization variables

This commit is contained in:
Ayaz Hafiz 2022-07-26 16:30:32 -04:00
parent 7926499900
commit fe864a445d
No known key found for this signature in database
GPG Key ID: 0E2A37416A25EF58

View File

@ -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
_ -> "<bad>"
"#
),
RocStr::from(
r#"{"actors":["Idris Elba","Mila Kunis"],"rating":{"average":7,"max":10,"min":1,"sentiment":{"Fresh":["tomatoes"]}},"year":2004}"#
),
RocStr
)
}