diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-12-05 20:11:56 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-12-05 20:11:56 +0000 |
| commit | 8b6c82d1114320eeca2695f4e2c1db9eca4ab361 (patch) | |
| tree | 21138852520bc46fd6525e88a99fa29e1585aa99 /src/test/java/org | |
| parent | 6be55e7252f1e9b03345ef23cfada39621fc817b (diff) | |
Add equality operation to SQL AST
Diffstat (limited to 'src/test/java/org')
2 files changed, 66 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 20d6dac..4f9771a 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 @@ -202,6 +202,19 @@ public class SqlWriterTests { // === Expressions === @Test + public void binaryOperationEquals() throws IOException { + var sql = SqlBinaryOperation.arbitrary() + .withOperator(SqlBinaryOperator.EQUALS) + .withLeft(SqlIntLiteral.arbitrary().withValue(42)) + .withRight(SqlIntLiteral.arbitrary().withValue(47)) + .build(); + + var string = write(writer -> writer.writeExpression(sql)); + + assertThat(string, equalTo("42 == 47")); + } + + @Test public void intLiteral() throws IOException { var sql = SqlIntLiteral.arbitrary() .withValue(42) diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlBinaryOperationMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlBinaryOperationMatcher.java new file mode 100644 index 0000000..fe79201 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlBinaryOperationMatcher.java @@ -0,0 +1,53 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.sql.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperationMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperationMatcher imports + +public final class SqlBinaryOperationMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperationMatcher isSqlBinaryOperation() { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperationMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperation>> submatchers; + + private SqlBinaryOperationMatcher( + java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperation>> 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.SqlBinaryOperation.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperationMatcher withOperator(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperator> operator) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperation>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("operator", org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperation::operator, (org.zwobble.precisely.Matcher) operator)); + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperationMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperationMatcher withLeft(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression> left) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperation>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("left", org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperation::left, (org.zwobble.precisely.Matcher) left)); + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperationMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperationMatcher withRight(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression> right) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperation>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("right", org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperation::right, (org.zwobble.precisely.Matcher) right)); + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperationMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperationMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperationMatcher body +} |
