From 35ed64a039a1a1a8683c962bfb320bf25d647cba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89amonn=20McManus?= Date: Thu, 30 Apr 2026 06:56:00 -0700 Subject: [PATCH] In JavadocFormattingTest, ensure that calling the formatter a second time does not change the output. PiperOrigin-RevId: 908146926 --- .../googlejavaformat/java/JavadocFormattingTest.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java b/core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java index b2332ee15..6977ac748 100644 --- a/core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java +++ b/core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java @@ -15,6 +15,7 @@ package com.google.googlejavaformat.java; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; import static com.google.common.truth.TruthJUnit.assume; import static java.nio.charset.StandardCharsets.UTF_8; @@ -915,16 +916,15 @@ class Test {} } @Test - public void brAtSignBug() { + public void brAtSignBug() throws FormatterException { /* * This is a bug -- more of a "spec" bug than an implementation bug, and hard to fix. * Fortunately, some very quick searching didn't turn up any instances in the Google codebase. */ - @SuppressWarnings("MisleadingEscapedSpace") // TODO(b/496180372): remove String input = """ /** - * abc
@foo\s + * abc
@foo */ class Test {}\ """; @@ -936,7 +936,9 @@ class Test {}\ */ class Test {} """; - doFormatTest(input, expected); + assertThat(formatter.formatSource(input)).isEqualTo(expected); + // This one is not idempotent since a second formatting round will introduce a blank line before + // the fake @foo tag. But the test is showing that there's a bug anyway. } @Test @@ -2051,6 +2053,8 @@ private void doFormatTest(String input, String expected) { try { String actual = formatter.formatSource(input); assertThat(actual).isEqualTo(expected); + String reformatted = formatter.formatSource(actual); + assertWithMessage("When checking idempotency").that(reformatted).isEqualTo(actual); } catch (FormatterException e) { throw new AssertionError(e); }