mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Add destructured inferred example
This commit is contained in:
parent
4ba132f7d0
commit
0ddbc172d7
1 changed files with 20 additions and 0 deletions
|
@ -1030,6 +1030,26 @@ fn decode_record_two_fields_string_and_string_infer_local_var() {
|
|||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn decode_record_two_fields_string_and_string_infer_local_var_destructured() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" imports [Decode, Json] provides [main] to "./platform"
|
||||
|
||||
main =
|
||||
decoded = Str.toUtf8 "{\"first\":\"ab\",\"second\":\"cd\"}" |> Decode.fromBytes Json.fromUtf8
|
||||
when decoded is
|
||||
Ok {first, second} -> Str.concat first second
|
||||
_ -> "something went wrong"
|
||||
"#
|
||||
),
|
||||
RocStr::from("abcd"),
|
||||
RocStr
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[ignore = "json parsing impl must be fixed first"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue