diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-05-17 10:08:19 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-05-17 10:08:19 +0100 |
| commit | 679f041d110605e7797795cd42ae6914193b9d88 (patch) | |
| tree | 54c877ad414740863fea302ae3aa3d5dc2f6a0f5 /src/test/java/org | |
| parent | 23985cff89b03270d429aedd1a7b5ccb0ec66073 (diff) | |
Add body to Java record node
Diffstat (limited to 'src/test/java/org')
| -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()); |
