mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-19 10:09:47 +00:00
Add more test gen for derived impls
This commit is contained in:
parent
df9bcb1a0c
commit
b61ffd3684
1 changed files with 47 additions and 0 deletions
|
@ -447,3 +447,50 @@ fn encode_derived_record_one_field_string() {
|
||||||
RocStr
|
RocStr
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(any(feature = "gen-llvm"))]
|
||||||
|
fn encode_derived_record_two_fields_strings() {
|
||||||
|
assert_evals_to!(
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
app "test"
|
||||||
|
imports [Encode.{ toEncoder }, Json]
|
||||||
|
provides [main] to "./platform"
|
||||||
|
|
||||||
|
main =
|
||||||
|
rcd = {a: "foo", b: "bar"}
|
||||||
|
result = Str.fromUtf8 (Encode.toBytes rcd Json.format)
|
||||||
|
when result is
|
||||||
|
Ok s -> s
|
||||||
|
_ -> "<bad>"
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
RocStr::from(r#"{"a":"foo","b":"bar",}"#),
|
||||||
|
RocStr
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(any(feature = "gen-llvm"))]
|
||||||
|
fn encode_derived_nested_record_string() {
|
||||||
|
assert_evals_to!(
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
app "test"
|
||||||
|
imports [Encode.{ toEncoder }, Json]
|
||||||
|
provides [main] to "./platform"
|
||||||
|
|
||||||
|
main =
|
||||||
|
rcd = {a: {b: "bar"}}
|
||||||
|
encoded = Encode.toBytes rcd Json.format
|
||||||
|
result = Str.fromUtf8 encoded
|
||||||
|
when result is
|
||||||
|
Ok s -> s
|
||||||
|
_ -> "<bad>"
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
RocStr::from(r#"{"a":{"b":"bar",},}"#),
|
||||||
|
RocStr
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue