diff options
Diffstat (limited to 'src/test')
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 24a57a6..5cb711a 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 @@ -850,6 +850,19 @@ public class RustWriterTests { assertThat(string, equalTo("x")); } + // === Literal patterns === + + @Test + public void literalPattern() throws IOException { + var rust = RustLiteralPattern.arbitrary() + .withLiteral(RustBoolLiteral.arbitrary().withValue(false)) + .build(); + + var string = write(writer -> writer.writePattern(rust)); + + assertThat(string, equalTo("false")); + } + // === Path patterns === @Test diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustLiteralPatternMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustLiteralPatternMatcher.java new file mode 100644 index 0000000..5af5abc --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustLiteralPatternMatcher.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.RustLiteralPatternMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLiteralPatternMatcher imports + +public class RustLiteralPatternMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLiteralPatternMatcher isRustLiteralPattern() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLiteralPatternMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLiteralPattern>> submatchers; + + private RustLiteralPatternMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLiteralPattern>> 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.RustLiteralPattern.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLiteralPatternMatcher withLiteral(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLiteralExpression> literal) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLiteralPattern>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("literal", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLiteralPattern::literal, literal)); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLiteralPatternMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLiteralPatternMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustLiteralPatternMatcher body +} |
