From 83cd529c660872f4e3a502cace62cd72a739ff05 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 1 Nov 2026 21:09:24 +0000 Subject: Extract Relation type --- .../compiler/ast/typed/RelationTableMatcher.java | 41 ++++++++++++++++++++++ .../ast/typed/TypedQueryDefinitionNodeMatcher.java | 4 +-- .../TypeCheckerQueryDefinitionTests.java | 3 +- 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/RelationTableMatcher.java (limited to 'src/test') diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/RelationTableMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/RelationTableMatcher.java new file mode 100644 index 0000000..3aff4dc --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/RelationTableMatcher.java @@ -0,0 +1,41 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.ast.typed; + +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.RelationTableMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.RelationTableMatcher imports + +public final class RelationTableMatcher implements org.zwobble.precisely.Matcher { + public static org.zwobble.hobgoblin.compiler.ast.typed.RelationTableMatcher isRelationTable() { + return new org.zwobble.hobgoblin.compiler.ast.typed.RelationTableMatcher(java.util.List.of()); + } + + private final java.util.List> submatchers; + + private RelationTableMatcher( + java.util.List> 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 toMatcher() { + return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.ast.typed.RelationTable.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.RelationTableMatcher withTable(org.zwobble.precisely.Matcher table) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("table", org.zwobble.hobgoblin.compiler.ast.typed.RelationTable::table, (org.zwobble.precisely.Matcher) table)); + return new org.zwobble.hobgoblin.compiler.ast.typed.RelationTableMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.RelationTableMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.RelationTableMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedQueryDefinitionNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedQueryDefinitionNodeMatcher.java index 651ede0..d9a6bc5 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedQueryDefinitionNodeMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedQueryDefinitionNodeMatcher.java @@ -36,9 +36,9 @@ public final class TypedQueryDefinitionNodeMatcher implements org.zwobble.precis return new org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNodeMatcher(submatchers); } - public org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNodeMatcher withTable(org.zwobble.precisely.Matcher table) { + public org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNodeMatcher withRelation(org.zwobble.precisely.Matcher relation) { var submatchers = new java.util.ArrayList>(this.submatchers); - submatchers.add(org.zwobble.precisely.Matchers.has("table", org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode::table, (org.zwobble.precisely.Matcher) table)); + submatchers.add(org.zwobble.precisely.Matchers.has("relation", org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode::relation, (org.zwobble.precisely.Matcher) relation)); return new org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNodeMatcher(submatchers); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerQueryDefinitionTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerQueryDefinitionTests.java index 4ecc1c6..66be9a7 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerQueryDefinitionTests.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerQueryDefinitionTests.java @@ -8,6 +8,7 @@ import org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTypeLevelReferenceNode; import org.zwobble.hobgoblin.compiler.sources.NullSource; import org.zwobble.hobgoblin.compiler.types.*; +import static org.zwobble.hobgoblin.compiler.ast.typed.RelationTableMatcher.isRelationTable; import static org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNodeMatcher.isTypedQueryDefinitionNode; import static org.zwobble.hobgoblin.compiler.typechecker.TypeCheckerTesting.typeCheckNamespaceStatement; import static org.zwobble.precisely.AssertThat.assertThat; @@ -34,7 +35,7 @@ public class TypeCheckerQueryDefinitionTests { assertThat(typed, isTypedQueryDefinitionNode() .withName(equalTo("allAuthors")) - .withTable(equalTo(table)) + .withRelation(isRelationTable().withTable(equalTo(table))) ); } } -- cgit v1.2.3