summaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-08-30 13:43:59 +0100
committerMichael Williamson <mike@zwobble.org>2026-08-30 13:43:59 +0100
commit93c7437d22224ac72818a4cd4ed4d9beeedaac79 (patch)
tree15b2e1a4944c4872701f610b426e82ec44c09e01 /src/test/java
parentd9945c3fd0dfa85bf0ca2bbb3af35af4b25b0fe7 (diff)
Add new calls to TypeScript AST
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriterTests.java26
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptNewCallMatcher.java47
2 files changed, 73 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 b0c583f..718f6e4 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
@@ -299,6 +299,32 @@ public class TypescriptWriterTests {
assertThat(string, equalTo("x.y"));
}
+ // === New calls ===
+
+ @Test
+ public void newCallWithoutArgs() throws IOException {
+ var typescript = TypescriptNewCall.arbitrary()
+ .withReceiver(ref("A"))
+ .build();
+
+ var string = write(writer -> writer.writeExpression(typescript));
+
+ assertThat(string, equalTo("new A()"));
+ }
+
+ @Test
+ public void newCallWithArgs() throws IOException {
+ var typescript = TypescriptNewCall.arbitrary()
+ .withReceiver(ref("A"))
+ .addArg(ref("b"))
+ .addArg(ref("c"))
+ .build();
+
+ var string = write(writer -> writer.writeExpression(typescript));
+
+ assertThat(string, equalTo("new A(b, c)"));
+ }
+
// === Number literals ===
@Test
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptNewCallMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptNewCallMatcher.java
new file mode 100644
index 0000000..491b0de
--- /dev/null
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptNewCallMatcher.java
@@ -0,0 +1,47 @@
+// Generated by hobgoblin.
+
+package org.zwobble.hobgoblin.compiler.output.lang.typescript.ast;
+
+// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNewCallMatcher imports
+// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNewCallMatcher imports
+
+public final class TypescriptNewCallMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> {
+ public static org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNewCallMatcher isTypescriptNewCall() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNewCallMatcher(java.util.List.of());
+ }
+
+ private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNewCall>> submatchers;
+
+ private TypescriptNewCallMatcher(
+ java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNewCall>> submatchers
+ ) {
+ this.submatchers = submatchers;
+ }
+
+ public org.zwobble.precisely.MatchResult match(java.lang.Object actual) {
+ return this.toMatcher().match(actual);
+ }
+
+ public org.zwobble.precisely.TextTree describe() {
+ return this.toMatcher().describe();
+ }
+
+ private org.zwobble.precisely.Matcher<java.lang.Object> toMatcher() {
+ return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNewCall.class, this.submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNewCallMatcher withReceiver(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExpression> receiver) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNewCall>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("receiver", org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNewCall::receiver, (org.zwobble.precisely.Matcher) receiver));
+ return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNewCallMatcher(submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNewCallMatcher withArgs(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExpression>> args) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNewCall>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("args", org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNewCall::args, (org.zwobble.precisely.Matcher) args));
+ return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNewCallMatcher(submatchers);
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNewCallMatcher body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNewCallMatcher body
+}