Skip to content

Commit 326fb9d

Browse files
eamonnmcmanusgoogle-java-format Team
authored andcommitted
In JavadocFormattingTest, ensure that calling the formatter a second time does not change the output.
PiperOrigin-RevId: 907865190
1 parent 70eb845 commit 326fb9d

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package com.google.googlejavaformat.java;
1616

1717
import static com.google.common.truth.Truth.assertThat;
18+
import static com.google.common.truth.Truth.assertWithMessage;
1819
import static com.google.common.truth.TruthJUnit.assume;
1920
import static java.nio.charset.StandardCharsets.UTF_8;
2021

@@ -915,16 +916,15 @@ class Test {}
915916
}
916917

917918
@Test
918-
public void brAtSignBug() {
919+
public void brAtSignBug() throws FormatterException {
919920
/*
920921
* This is a bug -- more of a "spec" bug than an implementation bug, and hard to fix.
921922
* Fortunately, some very quick searching didn't turn up any instances in the Google codebase.
922923
*/
923-
@SuppressWarnings("MisleadingEscapedSpace") // TODO(b/496180372): remove
924924
String input =
925925
"""
926926
/**
927-
* abc<br>@foo\s
927+
* abc<br>@foo
928928
*/
929929
class Test {}\
930930
""";
@@ -936,7 +936,9 @@ class Test {}\
936936
*/
937937
class Test {}
938938
""";
939-
doFormatTest(input, expected);
939+
assertThat(formatter.formatSource(input)).isEqualTo(expected);
940+
// This one is not idempotent since a second formatting round will introduce a blank line before
941+
// the fake @foo tag. But the test is showing that there's a bug anyway.
940942
}
941943

942944
@Test
@@ -2032,6 +2034,8 @@ private void doFormatTest(String input, String expected) {
20322034
try {
20332035
String actual = formatter.formatSource(input);
20342036
assertThat(actual).isEqualTo(expected);
2037+
String reformatted = formatter.formatSource(actual);
2038+
assertWithMessage("When checking idempotency").that(reformatted).isEqualTo(actual);
20352039
} catch (FormatterException e) {
20362040
throw new AssertionError(e);
20372041
}

0 commit comments

Comments
 (0)