mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Add deriving toEncoder for opaques
This commit is contained in:
parent
83813afeaf
commit
c4f9aa6fe6
3 changed files with 82 additions and 7 deletions
|
@ -374,6 +374,30 @@ fn encode_use_stdlib_without_wrapping_custom() {
|
|||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn encode_derive_to_encoder_for_opaque() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test"
|
||||
imports [Json]
|
||||
provides [main] to "./platform"
|
||||
|
||||
HelloWorld := { a: Str } has [Encoding]
|
||||
|
||||
main =
|
||||
result = Str.fromUtf8 (Encode.toBytes (@HelloWorld { a: "Hello, World!" }) Json.toUtf8)
|
||||
when result is
|
||||
Ok s -> s
|
||||
_ -> "<bad>"
|
||||
"#
|
||||
),
|
||||
RocStr::from(r#"{"a":"Hello, World!"}"#),
|
||||
RocStr
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn to_encoder_encode_custom_has_capture() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue