diff options
Diffstat (limited to 'src/test/java/org/zwobble')
| -rw-r--r-- | src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java index a6f7e45..0d36bcb 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java @@ -134,6 +134,7 @@ public class JavaWriterTests { "Point", List.of(), List.of(), + List.of(), DocComment.EMPTY ); @@ -151,6 +152,7 @@ public class JavaWriterTests { "Point", List.of(), List.of(), + List.of(), new DocComment("A 2D point.") ); @@ -164,6 +166,38 @@ public class JavaWriterTests { } @Test + public void recordDeclarationWithMethods() throws IOException { + var java = new JavaRecordDeclaration( + "Rectangle", + List.of(), + List.of(), + List.of( + new JavaMethodDeclaration( + "a", + JavaTypeRef.VOID + ), + new JavaMethodDeclaration( + "b", + JavaTypeRef.VOID + ) + ), + DocComment.EMPTY + ); + + var string = write(writer -> writer.writeTypeDeclaration(java)); + + assertThat(string, equalTo(""" + public record Rectangle() { + public void a() { + } + + public void b() { + } + }""" + )); + } + + @Test public void typeRefWithoutArgsHasNoAngleBrackets() throws IOException { var java = new JavaTypeRef(List.of("abc", "def"), "One", List.of()); |
