add tag union tests for trailing commas formatting

This commit is contained in:
Sébastien Besnier 2020-12-28 18:57:45 +01:00
parent 7692bd5671
commit 965d151168
2 changed files with 48 additions and 16 deletions

View File

@ -415,7 +415,7 @@ pub fn fmt_list<'a>(
for item in loc_items.iter() {
match &item.value {
// TODO?? These SpaceAfter/SpaceBefore litany seems overcomplicated
// Can we simplify this?
// Can we simplify this? Or at least move this in a separate function.
Expr::SpaceBefore(expr_below, spaces_above_expr) => {
newline(buf, item_indent);
fmt_comments_only(

View File

@ -2452,22 +2452,54 @@ mod test_fmt {
));
}
// TODO This raises a parse error:
// NotYetImplemented("TODO the : in this declaration seems outdented")
// #[test]
// fn multiline_tag_union_annotation() {
// expr_formats_same(indoc!(
// r#"
// b :
// [
// True,
// False,
// ]
#[test]
fn multiline_tag_union_annotation() {
expr_formats_same(indoc!(
r#"
b :
[
True,
False,
]
// b
// "#
// ));
// }
b
"#
));
}
#[test]
fn multiline_tag_union_annotation_with_final_comment() {
expr_formats_to(
indoc!(
r#"
b :
[
True,
# comment 1
False # comment 2
,
# comment 3
]
b
"#
),
indoc!(
r#"
b :
[
True,
# comment 1
False,
# comment 2
# comment 3
]
b
"#
),
);
}
#[test]
fn tag_union() {