From 76dba2d183609094788afafe0cebd2045b212882 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 22 Oct 2026 21:26:09 +0100 Subject: Parse query expression reference --- ...UntypedQueryExpressionReferenceNodeMatcher.java | 47 ++++++++++++++++++++++ .../ParserQueryExpressionReferenceTests.java | 22 ++++++++++ 2 files changed, 69 insertions(+) create mode 100644 src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedQueryExpressionReferenceNodeMatcher.java create mode 100644 src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserQueryExpressionReferenceTests.java (limited to 'src/test/java') diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedQueryExpressionReferenceNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedQueryExpressionReferenceNodeMatcher.java new file mode 100644 index 0000000..3e4dd49 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedQueryExpressionReferenceNodeMatcher.java @@ -0,0 +1,47 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.ast.untyped; + +// Custom area start: org.zwobble.hobgoblin.compiler.ast.untyped.UntypedQueryExpressionReferenceNodeMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.untyped.UntypedQueryExpressionReferenceNodeMatcher imports + +public final class UntypedQueryExpressionReferenceNodeMatcher implements org.zwobble.precisely.Matcher { + public static org.zwobble.hobgoblin.compiler.ast.untyped.UntypedQueryExpressionReferenceNodeMatcher isUntypedQueryExpressionReferenceNode() { + return new org.zwobble.hobgoblin.compiler.ast.untyped.UntypedQueryExpressionReferenceNodeMatcher(java.util.List.of()); + } + + private final java.util.List> submatchers; + + private UntypedQueryExpressionReferenceNodeMatcher( + 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.untyped.UntypedQueryExpressionReferenceNode.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.untyped.UntypedQueryExpressionReferenceNodeMatcher withName(org.zwobble.precisely.Matcher name) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.ast.untyped.UntypedQueryExpressionReferenceNode::name, (org.zwobble.precisely.Matcher) name)); + return new org.zwobble.hobgoblin.compiler.ast.untyped.UntypedQueryExpressionReferenceNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.untyped.UntypedQueryExpressionReferenceNodeMatcher withSource(org.zwobble.precisely.Matcher source) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("source", org.zwobble.hobgoblin.compiler.ast.untyped.UntypedQueryExpressionReferenceNode::source, (org.zwobble.precisely.Matcher) source)); + return new org.zwobble.hobgoblin.compiler.ast.untyped.UntypedQueryExpressionReferenceNodeMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.untyped.UntypedQueryExpressionReferenceNodeMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.untyped.UntypedQueryExpressionReferenceNodeMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserQueryExpressionReferenceTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserQueryExpressionReferenceTests.java new file mode 100644 index 0000000..bc911dc --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserQueryExpressionReferenceTests.java @@ -0,0 +1,22 @@ +package org.zwobble.hobgoblin.compiler.parser; + +import org.junit.jupiter.api.Test; + +import static org.zwobble.hobgoblin.compiler.ast.untyped.UntypedQueryExpressionReferenceNodeMatcher.isUntypedQueryExpressionReferenceNode; +import static org.zwobble.hobgoblin.compiler.parser.ParserTesting.parseString; +import static org.zwobble.precisely.AssertThat.assertThat; +import static org.zwobble.precisely.Matchers.equalTo; + +public class ParserQueryExpressionReferenceTests { + @Test + public void canParseReference() { + var source = "authors"; + + var node = parseString(source, Parser::parseQueryExpression); + + assertThat(node, isUntypedQueryExpressionReferenceNode() + .withName(equalTo("authors")) + ); + } +} + -- cgit v1.2.3