Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ void htmlPreTag() throws Throwable {
assertEquals(formatted, format(unformatted), "Failed to create internal code formatter. See Spotless issue #191");
}

@Test
void records() throws Throwable {
config.clear();
config.setProperty(
DefaultCodeFormatterConstants.FORMATTER_KEEP_RECORD_DECLARATION_ON_ONE_LINE,
DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY);
String formatted = getTestResource("java/eclipse/RecordsFormatted.test");
String unformatted = getTestResource("java/eclipse/RecordsUnformatted.test");
assertEquals(formatted, format(unformatted), "Jvm14 records not formatted. See Spotless issue #951");
}

private String format(final String input) throws Exception {
EclipseJdtFormatterStepImpl formatter = new EclipseJdtFormatterStepImpl(config);
return formatter.format(input);
Expand Down
9 changes: 9 additions & 0 deletions testlib/src/main/resources/java/eclipse/RecordsFormatted.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
public class Records {
public record EmptyRecordInOneLine(int a, int b) {}
public record CtorMultipleLines(int a, int b) {
public CtorMultipleLines(int a, int b) {
this.a = a;
this.b = b;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class Records {
public record EmptyRecordInOneLine(int a, int b) {
}
public record CtorMultipleLines(int a, int b) {
public CtorMultipleLines(int a, int b) { this.a = a; this.b = b; }
}
}