diff options
Diffstat (limited to 'src/test')
2 files changed, 65 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 da07c8a..21f8833 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 @@ -351,6 +351,8 @@ public class RustWriterTests { // == Expressions == + // === Block expressions === + @Test public void blockExpressionWithNoStatementsAndNoFinalOperand() throws IOException { var rust = RustBlockExpression.arbitrary().build(); @@ -418,6 +420,8 @@ public class RustWriterTests { }""")); } + // === Boolean literals === + @Test public void trueLiteral() throws IOException { var rust = RustBoolLiteral.arbitrary().withValue(true).build(); @@ -436,6 +440,8 @@ public class RustWriterTests { assertThat(string, equalTo("false")); } + // === Call expressions === + @Test public void callExpressionWithNoArgs() throws IOException { var rust = RustCallExpression.arbitrary() @@ -460,6 +466,20 @@ public class RustWriterTests { assertThat(string, equalTo("f(x, y)")); } + // === Field expressions === + + @Test + public void fieldExpression() throws IOException { + var rust = RustFieldExpression.arbitrary() + .withContainerOperand(RustPathInExpression.of("x")) + .withFieldName(RustIdentifier.of("y")) + .build(); + + var string = write(writer -> writer.writeExpression(rust)); + + assertThat(string, equalTo("x.y")); + } + // == Types == @Test diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustFieldExpressionMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustFieldExpressionMatcher.java new file mode 100644 index 0000000..ce26347 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustFieldExpressionMatcher.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.RustFieldExpressionMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustFieldExpressionMatcher imports + +public class RustFieldExpressionMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustFieldExpressionMatcher isRustFieldExpression() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustFieldExpressionMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustFieldExpression>> submatchers; + + private RustFieldExpressionMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustFieldExpression>> 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.RustFieldExpression.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustFieldExpressionMatcher withContainerOperand(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression> containerOperand) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustFieldExpression>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("containerOperand", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustFieldExpression::containerOperand, containerOperand)); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustFieldExpressionMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustFieldExpressionMatcher withFieldName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifier> fieldName) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustFieldExpression>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("fieldName", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustFieldExpression::fieldName, fieldName)); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustFieldExpressionMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustFieldExpressionMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustFieldExpressionMatcher body +} |
