diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-08-30 08:50:17 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-08-30 08:50:17 +0100 |
| commit | 065958bb0bbe55a40a1c3df0748bb0b1625f679f (patch) | |
| tree | 67210219fe2fdf364dec35a5f2e34d21d99d183b /src/test | |
| parent | b6976dcf7696daf01d4a5b698617fc190dfc8d65 (diff) | |
Write doc comments for structs
Diffstat (limited to 'src/test')
2 files changed, 26 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriterTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriterTests.java index f034fe0..acb4fea 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriterTests.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriterTests.java @@ -1,6 +1,7 @@ package org.zwobble.hobgoblin.compiler.output.lang.typescript; import org.junit.jupiter.api.Test; +import org.zwobble.hobgoblin.compiler.ast.DocComment; import org.zwobble.hobgoblin.compiler.output.CodeWriter; import org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.*; @@ -93,6 +94,25 @@ public class TypescriptWriterTests { )); } + @Test + public void classDeclarationWithDocComment() throws IOException { + var typescript = TypescriptClassDeclaration.arbitrary() + .withName(TypescriptIdentifier.of("X")) + .withDocComment(new DocComment("abc\ndef")) + .build(); + + var string = write(writer -> writer.writeStatement(typescript)); + + assertThat(string, equalTo(""" + /** + * abc + * def + */ + class X { + }""" + )); + } + // == Class elements == // === Class field declarations === diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptClassDeclarationMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptClassDeclarationMatcher.java index ff561bd..46eeaa2 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptClassDeclarationMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptClassDeclarationMatcher.java @@ -42,6 +42,12 @@ public final class TypescriptClassDeclarationMatcher implements org.zwobble.prec return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassDeclarationMatcher(submatchers); } + public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassDeclarationMatcher withDocComment(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.DocComment> docComment) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassDeclaration>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("docComment", org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassDeclaration::docComment, (org.zwobble.precisely.Matcher) docComment)); + return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassDeclarationMatcher(submatchers); + } + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassDeclarationMatcher body // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassDeclarationMatcher body } |
