diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-07-25 23:48:53 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-07-25 23:48:53 +0100 |
| commit | 051ea60dc8a775f0fc82ebbc5f65a8c5f57157c0 (patch) | |
| tree | 9dbf7cb23dddcb51ea6dbec56bbbe7cf060033a8 /src/test/java/org | |
| parent | 8f5993f7dc213f8130204c3ea6facd814373fb3d (diff) | |
Add type cases to Rust AST
Diffstat (limited to 'src/test/java/org')
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 fe1f9b4..55c8f54 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 @@ -842,6 +842,20 @@ public class RustWriterTests { assertThat(string, equalTo("(a, b, c)")); } + // === Type cast expressions === + + @Test + public void typeCastExpression() throws IOException { + var rust = RustTypeCastExpression.arbitrary() + .withLeft(RustPath.of("a")) + .withRight(RustPath.of("X")) + .build(); + + var string = write(writer -> writer.writeTopLevelExpression(rust)); + + assertThat(string, equalTo("a as X")); + } + // === Vec repeat expressions === @Test diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypeCastExpressionMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypeCastExpressionMatcher.java new file mode 100644 index 0000000..2ff190e --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypeCastExpressionMatcher.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.RustTypeCastExpressionMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeCastExpressionMatcher imports + +public class RustTypeCastExpressionMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeCastExpressionMatcher isRustTypeCastExpression() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeCastExpressionMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeCastExpression>> submatchers; + + private RustTypeCastExpressionMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeCastExpression>> 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.RustTypeCastExpression.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeCastExpressionMatcher withLeft(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression> left) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeCastExpression>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("left", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeCastExpression::left, left)); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeCastExpressionMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeCastExpressionMatcher withRight(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType> right) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeCastExpression>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("right", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeCastExpression::right, right)); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeCastExpressionMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeCastExpressionMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeCastExpressionMatcher body +} |
