mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Check in gen test for record decoding!
This commit is contained in:
parent
44a746b473
commit
60ed17155c
2 changed files with 12 additions and 8 deletions
|
@ -584,7 +584,15 @@ trait DerivableVisitor {
|
||||||
let descend = Self::visit_record(var)?;
|
let descend = Self::visit_record(var)?;
|
||||||
if descend.0 {
|
if descend.0 {
|
||||||
push_var_slice!(fields.variables());
|
push_var_slice!(fields.variables());
|
||||||
stack.push(ext);
|
if !matches!(
|
||||||
|
subs.get_content_without_compacting(ext),
|
||||||
|
Content::FlexVar(_) | Content::RigidVar(_)
|
||||||
|
) {
|
||||||
|
// TODO: currently, just we suppose the presence of a flex var may
|
||||||
|
// include more or less things which we can derive. But, we should
|
||||||
|
// instead recurse here, and add a `t ~ u | u has Decode` constraint as needed.
|
||||||
|
stack.push(ext);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TagUnion(tags, ext) => {
|
TagUnion(tags, ext) => {
|
||||||
|
|
|
@ -954,11 +954,7 @@ fn encode_then_decode_list_of_lists_of_strings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(all(
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||||
any(feature = "gen-llvm"), // currently fails on gen-wasm
|
|
||||||
not(feature = "gen-llvm-wasm") // hits a stack limit in wasm3
|
|
||||||
))]
|
|
||||||
#[ignore]
|
|
||||||
fn decode_record_two_fields() {
|
fn decode_record_two_fields() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
|
@ -967,11 +963,11 @@ fn decode_record_two_fields() {
|
||||||
|
|
||||||
main =
|
main =
|
||||||
when Str.toUtf8 "{\"first\":\"ab\",\"second\":\"cd\"}" |> Decode.fromBytes Json.fromUtf8 is
|
when Str.toUtf8 "{\"first\":\"ab\",\"second\":\"cd\"}" |> Decode.fromBytes Json.fromUtf8 is
|
||||||
Ok { first, second } -> Str.concat first second
|
Ok {first: "ab", second: "cd"} -> "abcd"
|
||||||
_ -> "something went wrong"
|
_ -> "something went wrong"
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
RocStr::from("ab "),
|
RocStr::from("abcd"),
|
||||||
RocStr
|
RocStr
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue