diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-07-02 09:27:01 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-07-02 09:27:01 +0100 |
| commit | 3e07c7c88343ae7ce92d43f326804a666c01ca11 (patch) | |
| tree | 9471ce955ba29df1c86367a5e1a5a5787ae00a74 /src/test/java | |
| parent | d0c6cc5511f5b953ca1a4184e6c7b903e4bb7450 (diff) | |
Add crate path segment
Diffstat (limited to 'src/test/java')
2 files changed, 42 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 f52d275..319393e 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 @@ -96,6 +96,15 @@ public class RustWriterTests { } @Test + public void crateTypeSegmentIsWritten() throws IOException { + var rust = RustTypePath.crate("a", "b"); + + var string = write(writer -> writer.writeType(rust)); + + assertThat(string, equalTo("crate::a::b")); + } + + @Test public void typeSegmentGenericArgsAreWritten() throws IOException { var rust = RustTypePath.of("std", "collections", "HashMap") .withArgs(List.of(RustTypePath.of("i32"), RustTypePath.of("f64"))); diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathIdentSegmentCrateMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathIdentSegmentCrateMatcher.java new file mode 100644 index 0000000..3a2285c --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathIdentSegmentCrateMatcher.java @@ -0,0 +1,33 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentCrateMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentCrateMatcher imports + +public class RustPathIdentSegmentCrateMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentCrateMatcher isRustPathIdentSegmentCrate() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentCrateMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentCrate>> submatchers; + + private RustPathIdentSegmentCrateMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentCrate>> 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.RustPathIdentSegmentCrate.class, this.submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentCrateMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentCrateMatcher body +} |
