summaryrefslogtreecommitdiff
path: root/src/test/java/org/zwobble
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-07-18 19:16:20 +0100
committerMichael Williamson <mike@zwobble.org>2026-07-18 19:16:20 +0100
commit9ebca11fc3d86ce4a5424e402503f5fbbc394468 (patch)
treeb275bb0b8c268c3df6b04557a3a703a11c40ceeb /src/test/java/org/zwobble
parentb94fc2c22021dc50381856f170fe9dca4b879468 (diff)
Add range 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.java14
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustRangeExprMatcher.java45
2 files changed, 59 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 e947db9..46180fb 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
@@ -682,6 +682,20 @@ public class RustWriterTests {
assertThat(string, equalTo("*x"));
}
+ // === Range exprs ===
+
+ @Test
+ public void rangeExpr() throws IOException {
+ var rust = RustRangeExpr.arbitrary()
+ .withStart(RustPath.of("x"))
+ .withEnd(RustPath.of("y"))
+ .build();
+
+ var string = write(writer -> writer.writeTopLevelExpression(rust));
+
+ assertThat(string, equalTo("x..y"));
+ }
+
// === Struct expressions ===
@Test
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustRangeExprMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustRangeExprMatcher.java
new file mode 100644
index 0000000..4044f9c
--- /dev/null
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustRangeExprMatcher.java
@@ -0,0 +1,45 @@
+// Generated by hobgoblin.
+
+package org.zwobble.hobgoblin.compiler.output.lang.rust.ast;
+
+// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustRangeExprMatcher imports
+// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustRangeExprMatcher imports
+
+public class RustRangeExprMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> {
+ public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustRangeExprMatcher isRustRangeExpr() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustRangeExprMatcher(java.util.List.of());
+ }
+
+ private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustRangeExpr>> submatchers;
+
+ private RustRangeExprMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustRangeExpr>> 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.RustRangeExpr.class, this.submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustRangeExprMatcher withStart(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression> start) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustRangeExpr>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("start", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustRangeExpr::start, start));
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustRangeExprMatcher(submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustRangeExprMatcher withEnd(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression> end) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustRangeExpr>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("end", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustRangeExpr::end, end));
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustRangeExprMatcher(submatchers);
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustRangeExprMatcher body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustRangeExprMatcher body
+}