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() { for item in loc_items.iter() {
match &item.value { match &item.value {
// TODO?? These SpaceAfter/SpaceBefore litany seems overcomplicated // 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) => { Expr::SpaceBefore(expr_below, spaces_above_expr) => {
newline(buf, item_indent); newline(buf, item_indent);
fmt_comments_only( fmt_comments_only(

View file

@ -2452,22 +2452,54 @@ mod test_fmt {
)); ));
} }
// TODO This raises a parse error: #[test]
// NotYetImplemented("TODO the : in this declaration seems outdented") fn multiline_tag_union_annotation() {
// #[test] expr_formats_same(indoc!(
// fn multiline_tag_union_annotation() { r#"
// expr_formats_same(indoc!( b :
// r#" [
// b : True,
// [ False,
// 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] #[test]
fn tag_union() { fn tag_union() {