diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-05-18 23:57:59 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-05-18 23:57:59 +0100 |
| commit | 1d80b1c242ef4188deac4921e6e67bd91ba6708f (patch) | |
| tree | 0de1951c6e19ca05c69ed7f53c44d76e798282e4 /src/test/java | |
| parent | 4e8d3aa3f1ec9372e97098d0c247ef104edfb012 (diff) | |
Support static method declarations in Java
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java | 27 |
1 files changed, 26 insertions, 1 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 531a7ff..f54f0bf 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 @@ -36,12 +36,14 @@ public class JavaWriterTests { List.of( new JavaMethodDeclaration( "a", + JavaMethodKind.INSTANCE, JavaTypeRef.VOID, List.of(), JavaBlock.EMPTY ), new JavaMethodDeclaration( "b", + JavaMethodKind.INSTANCE, JavaTypeRef.VOID, List.of(), JavaBlock.EMPTY @@ -178,12 +180,14 @@ public class JavaWriterTests { List.of( new JavaMethodDeclaration( "a", + JavaMethodKind.INSTANCE, JavaTypeRef.VOID, List.of(), JavaBlock.EMPTY ), new JavaMethodDeclaration( "b", + JavaMethodKind.INSTANCE, JavaTypeRef.VOID, List.of(), JavaBlock.EMPTY @@ -206,9 +210,10 @@ public class JavaWriterTests { } @Test - public void emptyMethod() throws IOException { + public void emptyInstanceMethod() throws IOException { var java = new JavaMethodDeclaration( "a", + JavaMethodKind.INSTANCE, JavaTypeRef.VOID, List.of(), JavaBlock.EMPTY @@ -223,9 +228,28 @@ public class JavaWriterTests { } @Test + public void emptyStaticMethod() throws IOException { + var java = new JavaMethodDeclaration( + "a", + JavaMethodKind.STATIC, + JavaTypeRef.VOID, + List.of(), + JavaBlock.EMPTY + ); + + var string = write(writer -> writer.writeMethodDeclaration(java)); + + assertThat(string, equalTo(""" + public static void a() { + }""" + )); + } + + @Test public void methodWithParams() throws IOException { var java = new JavaMethodDeclaration( "a", + JavaMethodKind.INSTANCE, JavaTypeRef.VOID, List.of( new JavaParam(JavaTypeRef.INT, "b"), @@ -246,6 +270,7 @@ public class JavaWriterTests { public void methodWithBody() throws IOException { var java = new JavaMethodDeclaration( "a", + JavaMethodKind.INSTANCE, JavaTypeRef.INT, List.of(), new JavaBlock(List.of( |
