diff options
Diffstat (limited to 'src/test/java/org/zwobble')
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 96cdc83..a6f8069 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 @@ -245,6 +245,19 @@ public class RustWriterTests { }""")); } + // == Statements == + + @Test + public void expressionStatementIsExpressionFollowedBySemicolon() throws IOException { + var rust = RustExpressionStatement.arbitrary() + .withExpression(RustBoolLiteral.arbitrary().withValue(true).build()) + .build(); + + var string = write(writer -> writer.writeStatement(rust)); + + assertThat(string, equalTo("true;")); + } + // == Expressions == @Test diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustExpressionStatementMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustExpressionStatementMatcher.java new file mode 100644 index 0000000..4e2479f --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustExpressionStatementMatcher.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.RustExpressionStatementMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpressionStatementMatcher imports + +public class RustExpressionStatementMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpressionStatementMatcher isRustExpressionStatement() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpressionStatementMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpressionStatement>> submatchers; + + private RustExpressionStatementMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpressionStatement>> 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.RustExpressionStatement.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpressionStatementMatcher withExpression(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression> expression) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpressionStatement>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("expression", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpressionStatement::expression, expression)); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpressionStatementMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpressionStatementMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpressionStatementMatcher body +} |
