summaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriterTests.java14
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustVecRepeatExpressionMatcher.java45
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 4279f49..bf93c1d 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
@@ -741,6 +741,20 @@ public class RustWriterTests {
assertThat(string, equalTo("(a, b, c)"));
}
+ // === Vec repeat expressions ===
+
+ @Test
+ public void vecRepeatExpression() throws IOException {
+ var rust = RustVecRepeatExpression.arbitrary()
+ .withRepeatOperand(RustIntegerLiteral.arbitrary().withValue(42))
+ .withLengthOperand(RustIntegerLiteral.arbitrary().withValue(47))
+ .build();
+
+ var string = write(writer -> writer.writeTopLevelExpression(rust));
+
+ assertThat(string, equalTo("vec![42; 47]"));
+ }
+
// === Precedence handling ===
@Test
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustVecRepeatExpressionMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustVecRepeatExpressionMatcher.java
new file mode 100644
index 0000000..9519a7b
--- /dev/null
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustVecRepeatExpressionMatcher.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.RustVecRepeatExpressionMatcher imports
+// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustVecRepeatExpressionMatcher imports
+
+public class RustVecRepeatExpressionMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> {
+ public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustVecRepeatExpressionMatcher isRustVecRepeatExpression() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustVecRepeatExpressionMatcher(java.util.List.of());
+ }
+
+ private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustVecRepeatExpression>> submatchers;
+
+ private RustVecRepeatExpressionMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustVecRepeatExpression>> 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.RustVecRepeatExpression.class, this.submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustVecRepeatExpressionMatcher 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.RustVecRepeatExpression>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("repeatOperand", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustVecRepeatExpression::repeatOperand, repeatOperand));
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustVecRepeatExpressionMatcher(submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustVecRepeatExpressionMatcher 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.RustVecRepeatExpression>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("lengthOperand", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustVecRepeatExpression::lengthOperand, lengthOperand));
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustVecRepeatExpressionMatcher(submatchers);
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustVecRepeatExpressionMatcher body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustVecRepeatExpressionMatcher body
+}