mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-22 16:30:04 +03:00
Record updating format
This commit is contained in:
parent
1706e24fd1
commit
b3bce7b0c4
@ -537,6 +537,19 @@ pub fn fmt_record<'a>(
|
|||||||
) {
|
) {
|
||||||
buf.push('{');
|
buf.push('{');
|
||||||
|
|
||||||
|
match _update {
|
||||||
|
None => {},
|
||||||
|
// We are presuming this to be a Var()
|
||||||
|
// If it wasnt a Var() we would not have made
|
||||||
|
// it this far. For example "{ 4 & hello = 9 }"
|
||||||
|
// doesnt make sense.
|
||||||
|
Some(record_var) => {
|
||||||
|
buf.push(' ');
|
||||||
|
fmt_expr(buf, &record_var.value, indent, false, false);
|
||||||
|
buf.push_str(" &");
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
let is_multiline = loc_fields
|
let is_multiline = loc_fields
|
||||||
.iter()
|
.iter()
|
||||||
.any(|loc_field| is_multiline_field(&loc_field.value));
|
.any(|loc_field| is_multiline_field(&loc_field.value));
|
||||||
|
@ -515,6 +515,59 @@ mod test_format {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn record_updating() {
|
||||||
|
expr_formats_same(indoc!(
|
||||||
|
r#"
|
||||||
|
{ shoes & leftShoe: nothing }
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
|
expr_formats_to(indoc!(
|
||||||
|
r#"
|
||||||
|
{ shoes & rightShoe : nothing }
|
||||||
|
"#
|
||||||
|
),indoc!(
|
||||||
|
r#"
|
||||||
|
{ shoes & rightShoe: nothing }
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
|
expr_formats_to(indoc!(
|
||||||
|
r#"
|
||||||
|
{ shoes & rightShoe : nothing }
|
||||||
|
"#
|
||||||
|
),indoc!(
|
||||||
|
r#"
|
||||||
|
{ shoes & rightShoe: nothing }
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
|
expr_formats_same(indoc!(
|
||||||
|
r#"
|
||||||
|
{ shoes &
|
||||||
|
rightShoe: newRightShoe,
|
||||||
|
leftShoe: newLeftShoe
|
||||||
|
}
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
|
expr_formats_to(indoc!(
|
||||||
|
r#"
|
||||||
|
{ shoes
|
||||||
|
& rightShoe: bareFoot
|
||||||
|
, leftShoe: bareFoot }
|
||||||
|
"#
|
||||||
|
), indoc!(
|
||||||
|
r#"
|
||||||
|
{ shoes &
|
||||||
|
rightShoe: bareFoot,
|
||||||
|
leftShoe: bareFoot
|
||||||
|
}
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
// #[test]
|
// #[test]
|
||||||
// fn record_field_destructuring() {
|
// fn record_field_destructuring() {
|
||||||
// expr_formats_same(indoc!(
|
// expr_formats_same(indoc!(
|
||||||
|
Loading…
Reference in New Issue
Block a user