diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-07-14 22:26:06 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-07-14 22:26:06 +0100 |
| commit | f429cfc456599b260a83816ab3761aec46e4a72c (patch) | |
| tree | ddd9f8e906058436ed87fabf9a227c877b7a36f2 /src/test/java | |
| parent | 81e9d4c913133ed400cff2c6abb0d51a004c1136 (diff) | |
Add array repeat expression to Rust AST
Diffstat (limited to 'src/test/java')
2 files changed, 59 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 800d77f..aa6c887 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 @@ -381,6 +381,20 @@ public class RustWriterTests { // == Expressions == + // === Array repeat expressions === + + @Test + public void arrayRepeatExpression() throws IOException { + var rust = RustArrayRepeatExpression.arbitrary() + .withRepeatOperand(RustIntegerLiteral.arbitrary().withValue(42)) + .withLengthOperand(RustIntegerLiteral.arbitrary().withValue(47)) + .build(); + + var string = write(writer -> writer.writeExpression(rust)); + + assertThat(string, equalTo("[42; 47]")); + } + // === Block expressions === @Test diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustArrayRepeatExpressionMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustArrayRepeatExpressionMatcher.java new file mode 100644 index 0000000..8ff968b --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustArrayRepeatExpressionMatcher.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.RustArrayRepeatExpressionMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustArrayRepeatExpressionMatcher imports + +public class RustArrayRepeatExpressionMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustArrayRepeatExpressionMatcher isRustArrayRepeatExpression() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustArrayRepeatExpressionMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustArrayRepeatExpression>> submatchers; + + private RustArrayRepeatExpressionMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustArrayRepeatExpression>> 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.RustArrayRepeatExpression.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustArrayRepeatExpressionMatcher withRepeatOperand(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression> repeatOperand) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustArrayRepeatExpression>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("repeatOperand", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustArrayRepeatExpression::repeatOperand, repeatOperand)); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustArrayRepeatExpressionMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustArrayRepeatExpressionMatcher withLengthOperand(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression> lengthOperand) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustArrayRepeatExpression>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("lengthOperand", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustArrayRepeatExpression::lengthOperand, lengthOperand)); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustArrayRepeatExpressionMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustArrayRepeatExpressionMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustArrayRepeatExpressionMatcher body +} |
