diff options
Diffstat (limited to 'src/test/java/org')
| -rw-r--r-- | src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java | 42 |
1 files changed, 35 insertions, 7 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 13c2c00..da0f26f 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 @@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test; import org.zwobble.hobgoblin.compiler.output.CodeWriter; import org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassDeclaration; import org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceDeclaration; +import org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodDeclaration; import org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef; import java.io.IOException; @@ -17,15 +18,44 @@ public class JavaWriterTests { @Test public void emptyClassDeclaration() throws IOException { var java = new JavaClassDeclaration( - "Rectangle" + "Rectangle", + List.of() ); var string = write(writer -> writer.writeTypeDeclaration(java)); assertThat(string, equalTo(""" public class Rectangle { - } - """ + }""" + )); + } + + @Test + public void classDeclarationWithMethods() throws IOException { + var java = new JavaClassDeclaration( + "Rectangle", + List.of( + new JavaMethodDeclaration( + "a", + JavaTypeRef.VOID + ), + new JavaMethodDeclaration( + "b", + JavaTypeRef.VOID + ) + ) + ); + + var string = write(writer -> writer.writeTypeDeclaration(java)); + + assertThat(string, equalTo(""" + public class Rectangle { + public void a() { + } + + public void b() { + } + }""" )); } @@ -40,8 +70,7 @@ public class JavaWriterTests { assertThat(string, equalTo(""" public sealed interface Shape { - } - """ + }""" )); } @@ -59,8 +88,7 @@ public class JavaWriterTests { assertThat(string, equalTo(""" public sealed interface Shape permits abc.def.One, abc.def.Two { - } - """ + }""" )); } |
