Deriving string encoders works

This commit is contained in:
Ayaz Hafiz 2022-06-24 17:50:46 -04:00
parent a17748ea01
commit 9826253785
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
11 changed files with 372 additions and 33 deletions

View file

@ -1467,6 +1467,24 @@ fn encode_custom_type() {
}
#[mono_test]
fn encode_derived_string() {
indoc!(
r#"
app "test"
imports [Encode.{ toEncoder }, Json]
provides [main] to "./platform"
main =
result = Str.fromUtf8 (Encode.toBytes "abc" Json.format)
when result is
Ok s -> s
_ -> "<bad>"
"#
)
}
#[mono_test]
#[ignore = "TODO"]
fn encode_derived_record() {
indoc!(
r#"
@ -1475,7 +1493,7 @@ fn encode_derived_record() {
provides [main] to "./platform"
main =
result = Str.fromUtf8 (Encode.toBytes {a: "fieldA", b: "fieldB"} Json.format)
result = Str.fromUtf8 (Encode.toBytes {a: "a"} Json.format)
when result is
Ok s -> s
_ -> "<bad>"