summaryrefslogtreecommitdiff
path: root/src/test/java/org/zwobble
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-07-19 17:20:11 +0100
committerMichael Williamson <mike@zwobble.org>2026-07-19 17:20:11 +0100
commita1e403d60400823a4f9e8d2ce933c1a02dab64a4 (patch)
treee78c8f77879b7e6f81010d7f232aad3d2d1da4a7 /src/test/java/org/zwobble
parent7eed843944a247a99e48bdb6f9dc3aac17d983c5 (diff)
Add patterns to Rust AST
Diffstat (limited to 'src/test/java/org/zwobble')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriterTests.java2
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIdentifierPatternMatcher.java39
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIteratorLoopExpressionMatcher.java4
3 files changed, 42 insertions, 3 deletions
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriterTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriterTests.java
index 46180fb..5ffebf1 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriterTests.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriterTests.java
@@ -626,7 +626,7 @@ public class RustWriterTests {
@Test
public void iteratorExpression() throws IOException {
var rust = RustIteratorLoopExpression.arbitrary()
- .withElementName(RustIdentifier.of("x"))
+ .withPattern(RustIdentifierPattern.arbitrary().withVariableName(RustIdentifier.of("x")))
.withElements(RustPath.of("xs"))
.withBody(RustBlockExpression.arbitrary()
.withFinalOperand(RustCallExpression.arbitrary()
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIdentifierPatternMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIdentifierPatternMatcher.java
new file mode 100644
index 0000000..4743c56
--- /dev/null
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIdentifierPatternMatcher.java
@@ -0,0 +1,39 @@
+// Generated by hobgoblin.
+
+package org.zwobble.hobgoblin.compiler.output.lang.rust.ast;
+
+// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifierPatternMatcher imports
+// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifierPatternMatcher imports
+
+public class RustIdentifierPatternMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> {
+ public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifierPatternMatcher isRustIdentifierPattern() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifierPatternMatcher(java.util.List.of());
+ }
+
+ private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifierPattern>> submatchers;
+
+ private RustIdentifierPatternMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifierPattern>> 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.rust.ast.RustIdentifierPattern.class, this.submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifierPatternMatcher withVariableName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifier> variableName) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifierPattern>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("variableName", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifierPattern::variableName, variableName));
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifierPatternMatcher(submatchers);
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifierPatternMatcher body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifierPatternMatcher body
+}
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIteratorLoopExpressionMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIteratorLoopExpressionMatcher.java
index 6bd153a..2f9d517 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIteratorLoopExpressionMatcher.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIteratorLoopExpressionMatcher.java
@@ -28,9 +28,9 @@ public class RustIteratorLoopExpressionMatcher implements org.zwobble.precisely.
return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIteratorLoopExpression.class, this.submatchers);
}
- public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIteratorLoopExpressionMatcher withElementName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifier> elementName) {
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIteratorLoopExpressionMatcher withPattern(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPattern> pattern) {
var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIteratorLoopExpression>>(this.submatchers);
- submatchers.add(org.zwobble.precisely.Matchers.has("elementName", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIteratorLoopExpression::elementName, elementName));
+ submatchers.add(org.zwobble.precisely.Matchers.has("pattern", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIteratorLoopExpression::pattern, pattern));
return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIteratorLoopExpressionMatcher(submatchers);
}