diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-05-29 17:03:35 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-05-29 17:03:35 +0100 |
| commit | e97fdb3a32e6c5eaae65d50001a2156ff8752f22 (patch) | |
| tree | 67d368d3a1bcfba034b81b30bbe215a314e028cc /src/test/java/org | |
| parent | ec184c5b7baccdc77a3dab790709838256546d21 (diff) | |
Support non-sealed interfaces in Java AST
Diffstat (limited to 'src/test/java/org')
| -rw-r--r-- | src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java | 31 |
1 files changed, 28 insertions, 3 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 a53b20f..c349ec1 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 @@ -94,9 +94,31 @@ public class JavaWriterTests { } @Test - public void emptyInterfaceDeclaration() throws IOException { + public void openInterfaceDeclaration() throws IOException { var java = new JavaInterfaceDeclaration( "Shape", + JavaInterfaceDeclaration.Openness.OPEN, + List.of(), + List.of(), + new JavaCustomArea(JavaTypeRef.topLevel(List.of(), "Shape"), "body"), + DocComment.EMPTY + ); + + var string = write(writer -> writer.writeTypeDeclaration(java)); + + assertThat(string, equalTo(""" + public interface Shape { + // Custom area start: Shape body + // Custom area end: Shape body + }""" + )); + } + + @Test + public void sealedInterfaceDeclaration() throws IOException { + var java = new JavaInterfaceDeclaration( + "Shape", + JavaInterfaceDeclaration.Openness.SEALED, List.of(), List.of(), new JavaCustomArea(JavaTypeRef.topLevel(List.of(), "Shape"), "body"), @@ -117,6 +139,7 @@ public class JavaWriterTests { public void sealedInterfaceDeclarationWithPermitsTypes() throws IOException { var java = new JavaInterfaceDeclaration( "Shape", + JavaInterfaceDeclaration.Openness.SEALED, List.of( JavaTypeRef.topLevel(List.of("abc", "def"), "One"), JavaTypeRef.topLevel(List.of("abc", "def"), "Two") @@ -140,6 +163,7 @@ public class JavaWriterTests { public void interfaceDeclarationWithDocComment() throws IOException { var java = new JavaInterfaceDeclaration( "Shape", + JavaInterfaceDeclaration.Openness.OPEN, List.of(), List.of(), new JavaCustomArea(JavaTypeRef.topLevel(List.of(), "Shape"), "body"), @@ -150,7 +174,7 @@ public class JavaWriterTests { assertThat(string, equalTo(""" /// A 2D shape. - public sealed interface Shape { + public interface Shape { // Custom area start: Shape body // Custom area end: Shape body }""" @@ -161,6 +185,7 @@ public class JavaWriterTests { public void interfaceDeclarationWithBody() throws IOException { var java = new JavaInterfaceDeclaration( "Shape", + JavaInterfaceDeclaration.Openness.OPEN, List.of(), List.of( new JavaMethodDeclaration( @@ -185,7 +210,7 @@ public class JavaWriterTests { var string = write(writer -> writer.writeTypeDeclaration(java)); assertThat(string, equalTo(""" - public sealed interface Shape { + public interface Shape { public static void a() { } |
