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.java13
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTryPropagationExpressionMatcher.java39
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 2568c42..bb40d71 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
@@ -628,6 +628,19 @@ public class RustWriterTests {
assertThat(string, equalTo("X { a: b, c: d }"));
}
+ // === Try propagation expressions ===
+
+ @Test
+ public void tryPropagationExpression() throws IOException {
+ var rust = RustTryPropagationExpression.arbitrary()
+ .withOperand(RustPath.of("a"))
+ .build();
+
+ var string = write(writer -> writer.writeExpression(rust));
+
+ assertThat(string, equalTo("a?"));
+ }
+
// == Types ==
@Test
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTryPropagationExpressionMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTryPropagationExpressionMatcher.java
new file mode 100644
index 0000000..171718c
--- /dev/null
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTryPropagationExpressionMatcher.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.RustTryPropagationExpressionMatcher imports
+// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTryPropagationExpressionMatcher imports
+
+public class RustTryPropagationExpressionMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> {
+ public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTryPropagationExpressionMatcher isRustTryPropagationExpression() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTryPropagationExpressionMatcher(java.util.List.of());
+ }
+
+ private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTryPropagationExpression>> submatchers;
+
+ private RustTryPropagationExpressionMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTryPropagationExpression>> 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.RustTryPropagationExpression.class, this.submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTryPropagationExpressionMatcher withOperand(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression> operand) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTryPropagationExpression>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("operand", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTryPropagationExpression::operand, operand));
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTryPropagationExpressionMatcher(submatchers);
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTryPropagationExpressionMatcher body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTryPropagationExpressionMatcher body
+}