summaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java62
1 files changed, 62 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 5595b62..e13c3dd 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
@@ -73,6 +73,26 @@ public class JavaWriterTests {
}
@Test
+ public void classDeclarationWithCustomArea() throws IOException {
+ var java = new JavaClassDeclaration(
+ "Point",
+ List.of(),
+ new JavaCustomArea(List.of("// <custom area>")),
+ DocComment.EMPTY
+ );
+
+ var string = write(writer -> writer.writeTypeDeclaration(java));
+
+ assertThat(string, equalTo("""
+ public class Point {
+ // Custom area start: body
+ // <custom area>
+ // Custom area end: body
+ }"""
+ ));
+ }
+
+ @Test
public void classDeclarationWithDocComment() throws IOException {
var java = new JavaClassDeclaration(
"Point",
@@ -134,6 +154,26 @@ public class JavaWriterTests {
}
@Test
+ public void interfaceDeclarationWithCustomArea() throws IOException {
+ var java = new JavaInterfaceDeclaration(
+ "Shape",
+ List.of(),
+ new JavaCustomArea(List.of("// <custom area>")),
+ DocComment.EMPTY
+ );
+
+ var string = write(writer -> writer.writeTypeDeclaration(java));
+
+ assertThat(string, equalTo("""
+ public sealed interface Shape {
+ // Custom area start: body
+ // <custom area>
+ // Custom area end: body
+ }"""
+ ));
+ }
+
+ @Test
public void interfaceDeclarationWithDocComment() throws IOException {
var java = new JavaInterfaceDeclaration(
"Shape",
@@ -175,6 +215,28 @@ public class JavaWriterTests {
}
@Test
+ public void recordDeclarationWithCustomArea() throws IOException {
+ var java = new JavaRecordDeclaration(
+ "Point",
+ List.of(),
+ List.of(),
+ List.of(),
+ new JavaCustomArea(List.of("// <custom area>")),
+ DocComment.EMPTY
+ );
+
+ var string = write(writer -> writer.writeTypeDeclaration(java));
+
+ assertThat(string, equalTo("""
+ public record Point() {
+ // Custom area start: body
+ // <custom area>
+ // Custom area end: body
+ }"""
+ ));
+ }
+
+ @Test
public void recordDeclarationWithDocComment() throws IOException {
var java = new JavaRecordDeclaration(
"Point",