summaryrefslogtreecommitdiff
path: root/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriterTests.java24
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustCallExpressionMatcher.java45
2 files changed, 69 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 2090c1e..2709df9 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
@@ -357,6 +357,30 @@ public class RustWriterTests {
assertThat(string, equalTo("false"));
}
+ @Test
+ public void callExpressionWithNoArgs() throws IOException {
+ var rust = RustCallExpression.arbitrary()
+ .withFunction(RustPathInExpression.of("f"))
+ .build();
+
+ var string = write(writer -> writer.writeExpression(rust));
+
+ assertThat(string, equalTo("f()"));
+ }
+
+ @Test
+ public void callExpressionWithArgs() throws IOException {
+ var rust = RustCallExpression.arbitrary()
+ .withFunction(RustPathInExpression.of("f"))
+ .addArg(RustPathInExpression.of("x"))
+ .addArg(RustPathInExpression.of("y"))
+ .build();
+
+ var string = write(writer -> writer.writeExpression(rust));
+
+ assertThat(string, equalTo("f(x, y)"));
+ }
+
// == Paths ==
@Test
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustCallExpressionMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustCallExpressionMatcher.java
new file mode 100644
index 0000000..a17d04d
--- /dev/null
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustCallExpressionMatcher.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.RustCallExpressionMatcher imports
+// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustCallExpressionMatcher imports
+
+public class RustCallExpressionMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> {
+ public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustCallExpressionMatcher isRustCallExpression() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustCallExpressionMatcher(java.util.List.of());
+ }
+
+ private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustCallExpression>> submatchers;
+
+ private RustCallExpressionMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustCallExpression>> 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.RustCallExpression.class, this.submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustCallExpressionMatcher withFunction(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression> function) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustCallExpression>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("function", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustCallExpression::function, function));
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustCallExpressionMatcher(submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustCallExpressionMatcher withArgs(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression>> args) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustCallExpression>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("args", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustCallExpression::args, args));
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustCallExpressionMatcher(submatchers);
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustCallExpressionMatcher body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustCallExpressionMatcher body
+}