summaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-08-30 13:36:30 +0100
committerMichael Williamson <mike@zwobble.org>2026-08-30 13:36:30 +0100
commitd9945c3fd0dfa85bf0ca2bbb3af35af4b25b0fe7 (patch)
tree4fe9d81fdc6b70edd195ec85d536230dcab4a69d /src/test/java
parentf917d90874048ae27efed68e3f5f8f960c3e6935 (diff)
Support static field declarations in TypeScript AST
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriterTests.java13
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptClassFieldDeclarationMatcher.java6
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));