diff options
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriterTests.java | 11 | ||||
| -rw-r--r-- | src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlParamRefMatcher.java | 41 |
2 files changed, 52 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriterTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriterTests.java index afbf80a..964f3c1 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriterTests.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriterTests.java @@ -259,6 +259,17 @@ public class SqlWriterTests { } @Test + public void paramRef() throws IOException { + var sql = SqlParamRef.arbitrary() + .withNumber(42) + .build(); + + var string = write(writer -> writer.writeExpression(sql)); + + assertThat(string, equalTo("?42")); + } + + @Test public void ref() throws IOException { var sql = ref("a"); diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlParamRefMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlParamRefMatcher.java new file mode 100644 index 0000000..edcddbd --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlParamRefMatcher.java @@ -0,0 +1,41 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.sql.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRefMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRefMatcher imports + +public final class SqlParamRefMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRefMatcher isSqlParamRef() { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRefMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef>> submatchers; + + private SqlParamRefMatcher( + java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef>> 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.sql.ast.SqlParamRef.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRefMatcher withNumber(org.zwobble.precisely.Matcher<? super java.lang.Integer> number) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("number", org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef::number, (org.zwobble.precisely.Matcher) number)); + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRefMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRefMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRefMatcher body +} |
