summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-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/RustIndexExpressionMatcher.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 b5dd515..8946855 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
@@ -650,6 +650,20 @@ public class RustWriterTests {
}"""));
}
+ // === Index expressions ==
+
+ @Test
+ public void indexExpression() throws IOException {
+ var rust = RustIndexExpression.arbitrary()
+ .withIndexed(RustPath.of("x"))
+ .withIndex(RustPath.of("y"))
+ .build();
+
+ var string = write(writer -> writer.writeTopLevelExpression(rust));
+
+ assertThat(string, equalTo("x[y]"));
+ }
+
// === Integer literals ===
@Test
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIndexExpressionMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIndexExpressionMatcher.java
new file mode 100644
index 0000000..4261e0e
--- /dev/null
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIndexExpressionMatcher.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.RustIndexExpressionMatcher imports
+// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIndexExpressionMatcher imports
+
+public class RustIndexExpressionMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> {
+ public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIndexExpressionMatcher isRustIndexExpression() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIndexExpressionMatcher(java.util.List.of());
+ }
+
+ private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIndexExpression>> submatchers;
+
+ private RustIndexExpressionMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIndexExpression>> 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.RustIndexExpression.class, this.submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIndexExpressionMatcher withIndexed(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression> indexed) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIndexExpression>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("indexed", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIndexExpression::indexed, indexed));
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIndexExpressionMatcher(submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIndexExpressionMatcher withIndex(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression> index) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIndexExpression>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("index", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIndexExpression::index, index));
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIndexExpressionMatcher(submatchers);
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIndexExpressionMatcher body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIndexExpressionMatcher body
+}