diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-06-27 22:28:48 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-06-27 23:25:48 +0100 |
| commit | 81168752fe9b588f7a8215f86a32f3154c3f593a (patch) | |
| tree | 7115bc38cd1e1e2f3cb91c6dc5b05bf854189d8e /src/test/java/org/zwobble | |
| parent | 6932fc110e1a6d734675a09fd6f5d889be1250b7 (diff) | |
Generate Rust types for structs
Diffstat (limited to 'src/test/java/org/zwobble')
9 files changed, 376 insertions, 15 deletions
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java index 909300e..992d9bd 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java @@ -975,21 +975,7 @@ public class JavaWriterTests { private String write(Write write, Optional<String> originalContents) throws IOException { var stringWriter = new StringWriter(); var javaWriter = JavaWriter.file( - new CodeWriter.CodeWriterFile() { - @Override - public String readString() throws IOException { - if (originalContents.isPresent()) { - return originalContents.get(); - } else { - throw new NoSuchFileException(""); - } - } - - @Override - public Writer openWriter() throws IOException { - return stringWriter; - } - } + new CodeWriter.InMemoryCodeWriterFile(originalContents, stringWriter) ); write.write(javaWriter); return stringWriter.toString(); 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 new file mode 100644 index 0000000..bc6f55e --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriterTests.java @@ -0,0 +1,104 @@ +package org.zwobble.hobgoblin.compiler.output.lang.rust; + +import org.junit.jupiter.api.Test; +import org.zwobble.hobgoblin.compiler.output.CodeWriter; +import org.zwobble.hobgoblin.compiler.output.lang.java.JavaWriter; +import org.zwobble.hobgoblin.compiler.output.lang.java.JavaWriterTests; +import org.zwobble.hobgoblin.compiler.output.lang.rust.ast.*; + +import java.io.IOException; +import java.io.StringWriter; +import java.util.List; +import java.util.Optional; + +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")); + } + + @Test + public void module() throws IOException { + var rust = new RustModule(List.of(new RustIdentifier("shapes")), List.of( + new RustStructStruct(new RustIdentifier("Rectangle"), List.of()), + new RustStructStruct(new RustIdentifier("Square"), List.of()) + )); + + var string = write(writer -> writer.writeModule(rust)); + + assertThat(string, equalTo(""" + pub struct Rectangle { + } + + pub struct Square { + } + """)); + } + + @Test + public void emptyStruct() throws IOException { + var rust = new RustStructStruct(new RustIdentifier("Rectangle"), List.of()); + + var string = write(writer -> writer.writeItem(rust)); + + assertThat(string, equalTo(""" + pub struct Rectangle { + }""")); + } + + @Test + public void emptyStructWithFields() throws IOException { + var rust = new RustStructStruct( + new RustIdentifier("Rectangle"), + List.of( + new RustStructField(new RustIdentifier("width"), RustTypePath.primitive("i32")), + new RustStructField(new RustIdentifier("height"), RustTypePath.primitive("i32")) + ) + ); + + var string = write(writer -> writer.writeItem(rust)); + + assertThat(string, equalTo(""" + pub struct Rectangle { + width: i32, + height: i32, + }""")); + } + + @Test + public void typeSegmentsAreSeparatedByDoubleColons() throws IOException { + var rust = RustTypePath.of("std", "string", "String"); + + var string = write(writer -> writer.writeType(rust)); + + assertThat(string, equalTo("std::string::String")); + } + + private String write(Write write) throws IOException { + return write(write, Optional.empty()); + } + + private String write(Write write, String originalContents) throws IOException { + return write(write, Optional.of(originalContents)); + } + + private String write(Write write, Optional<String> originalContents) throws IOException { + var stringWriter = new StringWriter(); + var rustWriter = RustWriter.file( + new CodeWriter.InMemoryCodeWriterFile(originalContents, stringWriter) + ); + write.write(rustWriter); + return stringWriter.toString(); + } + + private interface Write { + void write(RustWriter writer) throws IOException; + } +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIdentifierMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIdentifierMatcher.java new file mode 100644 index 0000000..3edd421 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustIdentifierMatcher.java @@ -0,0 +1,37 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifierMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifierMatcher imports + +public class RustIdentifierMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifierMatcher isRustIdentifier() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifierMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifier>> submatchers; + + private RustIdentifierMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifier>> 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.RustIdentifier.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifierMatcher withValue(org.zwobble.precisely.Matcher<? super String> value) { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifierMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("value", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifier::value, value))).toList()); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifierMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifierMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustModuleMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustModuleMatcher.java new file mode 100644 index 0000000..c6a1629 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustModuleMatcher.java @@ -0,0 +1,41 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustModuleMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustModuleMatcher imports + +public class RustModuleMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustModuleMatcher isRustModule() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustModuleMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustModule>> submatchers; + + private RustModuleMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustModule>> 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.RustModule.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustModuleMatcher withName(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifier>> name) { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustModuleMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustModule::name, name))).toList()); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustModuleMatcher withItems(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustItem>> items) { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustModuleMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("items", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustModule::items, items))).toList()); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustModuleMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustModuleMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathIdentSegmentIdentifierMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathIdentSegmentIdentifierMatcher.java new file mode 100644 index 0000000..5f79def --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathIdentSegmentIdentifierMatcher.java @@ -0,0 +1,37 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentIdentifierMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentIdentifierMatcher imports + +public class RustPathIdentSegmentIdentifierMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentIdentifierMatcher isRustPathIdentSegmentIdentifier() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentIdentifierMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentIdentifier>> submatchers; + + private RustPathIdentSegmentIdentifierMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentIdentifier>> 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.RustPathIdentSegmentIdentifier.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentIdentifierMatcher withName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifier> name) { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentIdentifierMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentIdentifier::name, name))).toList()); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentIdentifierMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentIdentifierMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStructFieldMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStructFieldMatcher.java new file mode 100644 index 0000000..a9b0b40 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStructFieldMatcher.java @@ -0,0 +1,41 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructFieldMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructFieldMatcher imports + +public class RustStructFieldMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructFieldMatcher isRustStructField() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructFieldMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructField>> submatchers; + + private RustStructFieldMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructField>> 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.RustStructField.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructFieldMatcher withName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifier> name) { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructFieldMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructField::name, name))).toList()); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructFieldMatcher withType(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType> type) { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructFieldMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructField::type, type))).toList()); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructFieldMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructFieldMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStructStructMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStructStructMatcher.java new file mode 100644 index 0000000..e8c6c39 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStructStructMatcher.java @@ -0,0 +1,41 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStructMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStructMatcher imports + +public class RustStructStructMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStructMatcher isRustStructStruct() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStructMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStruct>> submatchers; + + private RustStructStructMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStruct>> 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.RustStructStruct.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStructMatcher withName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifier> name) { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStructMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStruct::name, name))).toList()); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStructMatcher withFields(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructField>> fields) { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStructMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("fields", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStruct::fields, fields))).toList()); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStructMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStructMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathMatcher.java new file mode 100644 index 0000000..248141a --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathMatcher.java @@ -0,0 +1,37 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathMatcher imports + +public class RustTypePathMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathMatcher isRustTypePath() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath>> submatchers; + + private RustTypePathMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath>> 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.RustTypePath.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathMatcher withSegments(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment>> segments) { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("segments", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath::segments, segments))).toList()); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathSegmentMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathSegmentMatcher.java new file mode 100644 index 0000000..4a73997 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathSegmentMatcher.java @@ -0,0 +1,37 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher imports + +public class RustTypePathSegmentMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher isRustTypePathSegment() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment>> submatchers; + + private RustTypePathSegmentMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment>> 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.RustTypePathSegment.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher withPathIdentSegment(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment> pathIdentSegment) { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("pathIdentSegment", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment::pathIdentSegment, pathIdentSegment))).toList()); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher body +} |
