summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java33
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaStaticMethodCallMatcher.java6
2 files changed, 39 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java
index 68be253..fb41fa8 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java
@@ -1749,6 +1749,39 @@ public class JavaWriterTests {
assertThat(string, equalTo("one.Two.three"));
}
+ // === Static method calls ===
+
+ @Test
+ public void staticMethodCallWithoutTypeArgs() throws IOException {
+ var java = new JavaStaticMethodCall(
+ JavaTypeRef.topLevel(JavaPackageName.of("one"), JavaIdentifier.of("Two")),
+ List.of(),
+ JavaIdentifier.of("three"),
+ List.of()
+ );
+
+ var string = write(writer -> writer.writeTopLevelExpression(java));
+
+ assertThat(string, equalTo("one.Two.three()"));
+ }
+
+ @Test
+ public void staticMethodCallWithTypeArgs() throws IOException {
+ var java = new JavaStaticMethodCall(
+ JavaTypeRef.topLevel(JavaPackageName.of("one"), JavaIdentifier.of("Two")),
+ List.of(
+ JavaTypeRef.local(JavaIdentifier.of("T1")),
+ JavaTypeRef.local(JavaIdentifier.of("T2"))
+ ),
+ JavaIdentifier.of("three"),
+ List.of()
+ );
+
+ var string = write(writer -> writer.writeTopLevelExpression(java));
+
+ assertThat(string, equalTo("one.Two.<T1, T2>three()"));
+ }
+
// === Switch expressions ===
@Test
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaStaticMethodCallMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaStaticMethodCallMatcher.java
index eb48160..b7618be 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaStaticMethodCallMatcher.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaStaticMethodCallMatcher.java
@@ -36,6 +36,12 @@ public final class JavaStaticMethodCallMatcher implements org.zwobble.precisely.
return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCallMatcher(submatchers);
}
+ public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCallMatcher withTypeArgs(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef>> typeArgs) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("typeArgs", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall::typeArgs, typeArgs));
+ return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCallMatcher(submatchers);
+ }
+
public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCallMatcher withMethodName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> methodName) {
var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall>>(this.submatchers);
submatchers.add(org.zwobble.precisely.Matchers.has("methodName", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall::methodName, methodName));