summaryrefslogtreecommitdiff
path: root/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java12
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaLocalVariableDeclarationMatcher.java41
2 files changed, 53 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 cd74430..3967c2b 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
@@ -770,6 +770,18 @@ public class JavaWriterTests {
}
@Test
+ public void localVariableDeclaration() throws IOException {
+ var java = JavaLocalVariableDeclaration.arbitrary()
+ .withName(JavaIdentifier.of("count"))
+ .withInitializer(new JavaIntegerLiteral(42))
+ .build();
+
+ var string = write(writer -> writer.writeBlockStatement(java));
+
+ assertThat(string, equalTo("var count = 42;"));
+ }
+
+ @Test
public void returnStatement() throws IOException {
var java = new JavaReturn(new JavaIntegerLiteral(42));
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaLocalVariableDeclarationMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaLocalVariableDeclarationMatcher.java
new file mode 100644
index 0000000..24fa147
--- /dev/null
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaLocalVariableDeclarationMatcher.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.JavaLocalVariableDeclarationMatcher imports
+// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaLocalVariableDeclarationMatcher imports
+
+public class JavaLocalVariableDeclarationMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> {
+ public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaLocalVariableDeclarationMatcher isJavaLocalVariableDeclaration() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaLocalVariableDeclarationMatcher(java.util.List.of());
+ }
+
+ private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaLocalVariableDeclaration>> submatchers;
+
+ private JavaLocalVariableDeclarationMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaLocalVariableDeclaration>> 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.JavaLocalVariableDeclaration.class, this.submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaLocalVariableDeclarationMatcher withName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> name) {
+ return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaLocalVariableDeclarationMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaLocalVariableDeclaration::name, name))).toList());
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaLocalVariableDeclarationMatcher withInitializer(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> initializer) {
+ return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaLocalVariableDeclarationMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("initializer", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaLocalVariableDeclaration::initializer, initializer))).toList());
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaLocalVariableDeclarationMatcher body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaLocalVariableDeclarationMatcher body
+}