Add some tests for trailing commas in comments

This commit is contained in:
Richard Feldman 2022-07-06 15:17:19 -04:00
parent 61a05c7059
commit d2476099a5
No known key found for this signature in database
GPG key ID: 7E4127D1E4241798

View file

@ -199,6 +199,31 @@ mod test_fmt {
));
}
#[test]
fn comment_with_trailing_space() {
expr_formats_to(
&format!(
indoc!(
r#"
# first comment{space}
x = 0 # second comment{space}
x
"#
),
space = " ",
),
indoc!(
r#"
# first comment
x = 0 # second comment
x
"#
),
);
}
#[test]
fn def_with_inline_comment() {
expr_formats_same(indoc!(
@ -4393,6 +4418,37 @@ mod test_fmt {
);
}
#[test]
fn module_defs_with_comments() {
module_formats_to(
&format!(
indoc!(
r#"
interface Foo
exposes []
imports []
# comment 1{space}
def = "" # comment 2{space}
# comment 3{space}
"#
),
space = " "
),
indoc!(
r#"
interface Foo
exposes []
imports []
# comment 1
def = "" # comment 2
# comment 3
"#
),
);
}
#[test]
fn format_tui_package_config() {
// At one point this failed to reformat.