summaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java13
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaClassLiteralMatcher.java41
2 files changed, 54 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 f45a432..15dbbbd 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
@@ -1457,6 +1457,19 @@ public class JavaWriterTests {
assertThat(string, equalTo("(int) 42"));
}
+ // === Class literals ===
+
+ @Test
+ public void classLiterals() throws IOException {
+ var java = JavaClassLiteral.arbitrary()
+ .withType(JavaTypeRef.topLevel(JavaPackageName.EMPTY, JavaIdentifier.of("X")))
+ .build();
+
+ var string = write(writer -> writer.writeTopLevelExpression(java));
+
+ assertThat(string, equalTo("X.class"));
+ }
+
// === Field accesses ===
@Test
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaClassLiteralMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaClassLiteralMatcher.java
new file mode 100644
index 0000000..4ecbab6
--- /dev/null
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaClassLiteralMatcher.java
@@ -0,0 +1,41 @@
+// Generated by hobgoblin.
+
+package org.zwobble.hobgoblin.compiler.output.lang.java.ast;
+
+// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassLiteralMatcher imports
+// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassLiteralMatcher imports
+
+public final class JavaClassLiteralMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> {
+ public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassLiteralMatcher isJavaClassLiteral() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassLiteralMatcher(java.util.List.of());
+ }
+
+ private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassLiteral>> submatchers;
+
+ private JavaClassLiteralMatcher(
+ java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassLiteral>> 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.java.ast.JavaClassLiteral.class, this.submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassLiteralMatcher withType(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef> type) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassLiteral>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassLiteral::type, type));
+ return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassLiteralMatcher(submatchers);
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassLiteralMatcher body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassLiteralMatcher body
+}