mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 04:08:19 +00:00
Support deriving Decode for opaques
This commit is contained in:
parent
61ba59de07
commit
1d885c4ab2
3 changed files with 115 additions and 2 deletions
|
@ -791,6 +791,32 @@ fn decode_use_stdlib() {
|
|||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(
|
||||
any(feature = "gen-llvm", feature = "gen-wasm"),
|
||||
not(debug_assertions) // https://github.com/roc-lang/roc/issues/3898
|
||||
))]
|
||||
fn decode_derive_decoder_for_opaque() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test"
|
||||
imports [Json]
|
||||
provides [main] to "./platform"
|
||||
|
||||
HelloWorld := { a: Str } has [Decoding]
|
||||
|
||||
main =
|
||||
when Str.toUtf8 """{"a":"Hello, World!"}""" |> Decode.fromBytes Json.fromUtf8 is
|
||||
Ok (@HelloWorld {a}) -> a
|
||||
_ -> "FAIL"
|
||||
"#
|
||||
),
|
||||
RocStr::from(r#"Hello, World!"#),
|
||||
RocStr
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn decode_use_stdlib_json_list() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue