Skip to content

Commit b06ccee

Browse files
committed
Expect what the command line prints for a comment in a module name
ModuleImportTest held formatSourceAndFixImports to what it wrote when it fixed the imports before formatting: the formatter broke "import module java./* comment */ base;" after the dot, and the line stayed broken. The command line fixes the imports after formatting, where ImportOrderer joins the line again, and formatSourceAndFixImports now does the same (#219). The test runs on JDK 25 and later only, where import module parses, so the JDK 21 build passed without this and the JDK 25 to 28 builds failed.
1 parent b445927 commit b06ccee

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

‎open-java-format/src/test/java/com/palantir/javaformat/java/ModuleImportTest.java‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,10 @@ class Example {}
115115
assertThat(Formatter.create().fixImports(input)).isEqualTo(reordered);
116116
assertThat(Formatter.create().fixImports(reordered)).isEqualTo(reordered);
117117

118-
// Formatting then breaks the line after the dot, which is where the formatter puts a comment
119-
// in a qualified name; that output is stable too.
120-
String formatted = """
121-
import module java.
122-
/* comment */ base;
123-
124-
class Example {}
125-
""";
126-
assertThat(Formatter.create().formatSourceAndFixImports(input)).isEqualTo(formatted);
127-
assertThat(Formatter.create().formatSourceAndFixImports(formatted)).isEqualTo(formatted);
118+
// Formatting breaks the line after the dot, which is where the formatter puts a comment in a
119+
// qualified name, and reordering, which comes after it as on the command line, joins it again.
120+
assertThat(Formatter.create().formatSourceAndFixImports(input)).isEqualTo(reordered);
121+
assertThat(Formatter.create().formatSourceAndFixImports(reordered)).isEqualTo(reordered);
128122
}
129123

130124
@Test

0 commit comments

Comments
 (0)