1515package com .google .googlejavaformat .java ;
1616
1717import static com .google .common .truth .Truth .assertThat ;
18+ import static com .google .common .truth .Truth .assertWithMessage ;
1819import static com .google .common .truth .TruthJUnit .assume ;
1920import 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