diff options
Diffstat (limited to 'src/test')
2 files changed, 62 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 358d99d..625526b 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 @@ -338,6 +338,8 @@ public class RustWriterTests { // == Statements == + // === Expression statements === + @Test public void expressionStatementIsExpressionFollowedBySemicolon() throws IOException { var rust = RustExpressionStatement.arbitrary() @@ -349,6 +351,21 @@ public class RustWriterTests { assertThat(string, equalTo("true;")); } + // === Let statements === + + @Test + public void letStatementDeclaringSingleVariable() throws IOException { + var rust = RustLetStatement.arbitrary() + .withVariableName(RustIdentifier.of("x")) + .withValue(RustBoolLiteral.arbitrary().withValue(true).build()) + .build(); + + var string = write(writer -> writer.writeStatement(rust)); + + assertThat(string, equalTo("let x = true;")); + + } + // == Expressions == // === Block expressions === diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustLetStatementMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustLetStatementMatcher.java new file mode 100644 index 0000000..c71dd98 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustLetStatementMatcher.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.RustLetStatementMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLetStatementMatcher imports + +public class RustLetStatementMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLetStatementMatcher isRustLetStatement() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLetStatementMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLetStatement>> submatchers; + + private RustLetStatementMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLetStatement>> 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.RustLetStatement.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLetStatementMatcher withVariableName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifier> variableName) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLetStatement>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("variableName", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLetStatement::variableName, variableName)); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLetStatementMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLetStatementMatcher withValue(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression> value) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLetStatement>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("value", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLetStatement::value, value)); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLetStatementMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLetStatementMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLetStatementMatcher body +} |
