diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-05-23 11:33:47 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-05-23 11:33:47 +0100 |
| commit | 1cc30d7d45377b98ee754e248149bf2f0cc485fb (patch) | |
| tree | 0362c2f12c0e467cb8d0c635981ad7734f6d03a6 /src/test | |
| parent | 4575cd222aa78442d41373b710be0640b24871c5 (diff) | |
Write custom area content
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java | 62 |
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", |
