From 514a0eefe86174ba535f46f3fb3481c539b79f96 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 2 Jul 2026 09:36:57 +0100 Subject: Reorder rust writer code to match AST definitions --- .../compiler/output/lang/rust/RustWriterTests.java | 24 ++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/test') 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 319393e..f4103c2 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 @@ -14,14 +14,7 @@ import static org.zwobble.precisely.AssertThat.assertThat; import static org.zwobble.precisely.Matchers.equalTo; public class RustWriterTests { - @Test - public void identifierNonKeywordIsWrittenVerbatim() throws IOException { - var rust = new RustIdentifier("rigs"); - - var string = write(writer -> writer.writeIdentifier(rust)); - - assertThat(string, equalTo("rigs")); - } + // == Modules == @Test public void module() throws IOException { @@ -41,6 +34,8 @@ public class RustWriterTests { """)); } + // == Items == + @Test public void emptyStruct() throws IOException { var rust = RustStructStruct.arbitrary().withName(new RustIdentifier("Rectangle")).build(); @@ -86,6 +81,8 @@ public class RustWriterTests { }""")); } + // == Types == + @Test public void typeSegmentsAreSeparatedByDoubleColons() throws IOException { var rust = RustTypePath.of("std", "string", "String"); @@ -114,6 +111,17 @@ public class RustWriterTests { assertThat(string, equalTo("std::collections::HashMap")); } + // == Identifiers == + + @Test + public void identifierNonKeywordIsWrittenVerbatim() throws IOException { + var rust = new RustIdentifier("rigs"); + + var string = write(writer -> writer.writeIdentifier(rust)); + + assertThat(string, equalTo("rigs")); + } + private String write(Write write) throws IOException { return write(write, Optional.empty()); } -- cgit v1.2.3