summaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-12-05 21:37:21 +0000
committerMichael Williamson <mike@zwobble.org>2026-12-05 21:37:21 +0000
commit5a646ae3ae92b9756e005b38e40f9fd8476cdc7c (patch)
tree5a1edc8c98d8d3e19f04cab0c8e92122a8aba1b4 /src/test/java
parentc2c7d9d6ecdbd5ab361d90e420e4460c8a68a7dc (diff)
Add param refs to SQL AST
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriterTests.java11
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlParamRefMatcher.java41
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
+}