diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-07-14 22:20:51 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-07-14 22:20:51 +0100 |
| commit | 81e9d4c913133ed400cff2c6abb0d51a004c1136 (patch) | |
| tree | b4b6d3203163d6dcdab649ec636ff9ab1bc446b1 /src/test | |
| parent | b7ea6f45e9b2b967fffdc6bc1e21ffd8ebf611e8 (diff) | |
Add integer literal to Rust AST
Diffstat (limited to 'src/test')
2 files changed, 50 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 d674346..800d77f 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 @@ -510,6 +510,17 @@ public class RustWriterTests { assertThat(string, equalTo("x.y")); } + // === Integer literals === + + @Test + public void integerLiteral() throws IOException { + var rust = RustIntegerLiteral.arbitrary().withValue(123).build(); + + var string = write(writer -> writer.writeExpression(rust)); + + assertThat(string, equalTo("123")); + } + // === Prefix expressions === @Test diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIntegerLiteralMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIntegerLiteralMatcher.java new file mode 100644 index 0000000..f27b21f --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIntegerLiteralMatcher.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.RustIntegerLiteralMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteralMatcher imports + +public class RustIntegerLiteralMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteralMatcher isRustIntegerLiteral() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteralMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral>> submatchers; + + private RustIntegerLiteralMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral>> 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.RustIntegerLiteral.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteralMatcher withValue(org.zwobble.precisely.Matcher<? super java.lang.Long> value) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("value", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteral::value, value)); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteralMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteralMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIntegerLiteralMatcher body +} |
