diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-08-29 22:23:25 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-08-29 22:23:25 +0100 |
| commit | 47eb39b664e9e7565086c2c6f5a79dd1d1b94a86 (patch) | |
| tree | 60e58809967db8e89339e5885b11b34c4f646216 /src/test/java | |
| parent | bd664e8cffcaf997631c9a8f5a5770d5a8bbe4d7 (diff) | |
Add body to Typescript modules
Diffstat (limited to 'src/test/java')
2 files changed, 31 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 a5cf539..a375b13 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 @@ -29,6 +29,31 @@ public class TypescriptWriterTests { )); } + @Test + public void moduleWithStatements() throws IOException { + var typescript = TypescriptModule.arbitrary() + .addBodyElement(TypescriptClassDeclaration.arbitrary() + .withName(TypescriptIdentifier.of("X")) + ) + .addBodyElement(TypescriptClassDeclaration.arbitrary() + .withName(TypescriptIdentifier.of("Y")) + ) + .build(); + + var string = write(writer -> writer.writeModule(typescript)); + + assertThat(string, equalTo(""" + // Generated by hobgoblin. + + class X { + } + + class Y { + } + """ + )); + } + // == Statements == // === Class declarations === diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptModuleMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptModuleMatcher.java index 2a9f2f5..c1bc764 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptModuleMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptModuleMatcher.java @@ -36,6 +36,12 @@ public final class TypescriptModuleMatcher implements org.zwobble.precisely.Matc return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptModuleMatcher(submatchers); } + public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptModuleMatcher withBody(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptStatement>> body) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptModule>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("body", org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptModule::body, body)); + return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptModuleMatcher(submatchers); + } + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptModuleMatcher body // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptModuleMatcher body } |
