diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-07-19 17:26:35 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-07-19 17:26:35 +0100 |
| commit | c4e0e6e62565c9e601ff45a366cf5dd31324c13c (patch) | |
| tree | 293ff6173b059855e8fa58b6a3c5902f7c15b3e0 /src/test/java | |
| parent | 775dd0f5eab8cc1c0c83824230708bf5e06f53da (diff) | |
Add path patterns to Rust AST
Diffstat (limited to 'src/test/java')
2 files changed, 52 insertions, 0 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 d036f78..24a57a6 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 @@ -850,6 +850,19 @@ public class RustWriterTests { assertThat(string, equalTo("x")); } + // === Path patterns === + + @Test + public void pathPattern() throws IOException { + var rust = RustPathPattern.arbitrary() + .withPath(RustPath.of("X", "Y")) + .build(); + + var string = write(writer -> writer.writePattern(rust)); + + assertThat(string, equalTo("X::Y")); + } + // === Wildcard patterns === @Test diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathPatternMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathPatternMatcher.java new file mode 100644 index 0000000..b231b83 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathPatternMatcher.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.RustPathPatternMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathPatternMatcher imports + +public class RustPathPatternMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathPatternMatcher isRustPathPattern() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathPatternMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathPattern>> submatchers; + + private RustPathPatternMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathPattern>> 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.RustPathPattern.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathPatternMatcher withPath(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath> path) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathPattern>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("path", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathPattern::path, path)); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathPatternMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathPatternMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathPatternMatcher body +} |
