summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-07-26 11:47:38 +0100
committerMichael Williamson <mike@zwobble.org>2026-07-26 11:47:38 +0100
commitb86689ba0ed73567993f304f963479633c8d0352 (patch)
treebf74806ef4ceb982153b4e12072f1cb3ff1b2c57 /src/test
parentf47074c2955d97c581255886b6597bbc95a4ff10 (diff)
Add string literals to Rust AST
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriterTests.java13
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStringLiteralMatcher.java39
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 1b3fdac..e9edb72 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
@@ -787,6 +787,19 @@ public class RustWriterTests {
assertThat(string, equalTo("x..y"));
}
+ // === String literals ===
+
+ @Test
+ public void stringLiteral() throws IOException {
+ var rust = RustStringLiteral.arbitrary()
+ .withValue("hello")
+ .build();
+
+ var string = write(writer -> writer.writeTopLevelExpression(rust));
+
+ assertThat(string, equalTo("\"hello\""));
+ }
+
// === Struct expressions ===
@Test
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStringLiteralMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStringLiteralMatcher.java
new file mode 100644
index 0000000..33965cc
--- /dev/null
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStringLiteralMatcher.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.RustStringLiteralMatcher imports
+// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStringLiteralMatcher imports
+
+public class RustStringLiteralMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> {
+ public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStringLiteralMatcher isRustStringLiteral() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStringLiteralMatcher(java.util.List.of());
+ }
+
+ private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStringLiteral>> submatchers;
+
+ private RustStringLiteralMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStringLiteral>> 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.RustStringLiteral.class, this.submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStringLiteralMatcher withValue(org.zwobble.precisely.Matcher<? super String> value) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStringLiteral>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("value", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStringLiteral::value, value));
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStringLiteralMatcher(submatchers);
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStringLiteralMatcher body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStringLiteralMatcher body
+}