diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-08-30 13:36:30 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-08-30 13:36:30 +0100 |
| commit | d9945c3fd0dfa85bf0ca2bbb3af35af4b25b0fe7 (patch) | |
| tree | 4fe9d81fdc6b70edd195ec85d536230dcab4a69d /src/test/java | |
| parent | f917d90874048ae27efed68e3f5f8f960c3e6935 (diff) | |
Support static field declarations in TypeScript AST
Diffstat (limited to 'src/test/java')
2 files changed, 19 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 bca5ab3..b0c583f 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 @@ -212,6 +212,19 @@ public class TypescriptWriterTests { } @Test + public void staticClassFieldDeclarationWithoutInitialValue() throws IOException { + var typescript = TypescriptClassFieldDeclaration.arbitrary() + .withVisibility(TypescriptVisibility.PUBLIC) + .withName(id("a")) + .withIsStatic(true) + .build(); + + var string = write(writer -> writer.writeClassElement(typescript)); + + assertThat(string, equalTo("public static a;")); + } + + @Test public void classFieldDeclarationWithExplicitType() throws IOException { var typescript = TypescriptClassFieldDeclaration.arbitrary() .withVisibility(TypescriptVisibility.PUBLIC) diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptClassFieldDeclarationMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptClassFieldDeclarationMatcher.java index 718e4ae..62a3f9e 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptClassFieldDeclarationMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptClassFieldDeclarationMatcher.java @@ -42,6 +42,12 @@ public final class TypescriptClassFieldDeclarationMatcher implements org.zwobble return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassFieldDeclarationMatcher(submatchers); } + public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassFieldDeclarationMatcher withIsStatic(org.zwobble.precisely.Matcher<? super java.lang.Boolean> isStatic) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassFieldDeclaration>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("isStatic", org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassFieldDeclaration::isStatic, (org.zwobble.precisely.Matcher) isStatic)); + return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassFieldDeclarationMatcher(submatchers); + } + public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassFieldDeclarationMatcher withType(org.zwobble.precisely.Matcher<? super java.util.Optional<org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExpression>> type) { var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassFieldDeclaration>>(this.submatchers); submatchers.add(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassFieldDeclaration::type, (org.zwobble.precisely.Matcher) type)); |
