mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Deriving string encoders works
This commit is contained in:
parent
a17748ea01
commit
9826253785
11 changed files with 372 additions and 33 deletions
|
@ -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>"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue