diff options
Diffstat (limited to 'src/test/java/org/zwobble')
2 files changed, 22 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 b8179f2..feabc12 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 @@ -213,6 +213,22 @@ public class RustWriterTests { } @Test + public void structWithTypeParams() throws IOException { + var rust = RustStructStruct.arbitrary() + .withName(RustIdentifier.of("X")) + .addTypeParam(RustTypeParam.arbitrary().withName(RustIdentifier.of("T1"))) + .addTypeParam(RustTypeParam.arbitrary().withName(RustIdentifier.of("T2"))) + .withFields(List.of()) + .build(); + + var string = write(writer -> writer.writeItem(rust)); + + assertThat(string, equalTo(""" + pub struct X<T1, T2> { + }""")); + } + + @Test public void structWithFields() throws IOException { var rust = RustStructStruct.arbitrary() .withName(new RustIdentifier("Rectangle")) 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 index b4c984d..b10f3c6 100644 --- 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 @@ -42,6 +42,12 @@ public final class RustStructStructMatcher implements org.zwobble.precisely.Matc return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStructMatcher(submatchers); } + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStructMatcher withTypeParams(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeParam>> typeParams) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStruct>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("typeParams", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStruct::typeParams, typeParams)); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStructMatcher(submatchers); + } + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStructMatcher withFields(org.zwobble.precisely.Matcher<? super java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructField>>> fields) { var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStruct>>(this.submatchers); submatchers.add(org.zwobble.precisely.Matchers.has("fields", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructStruct::fields, fields)); |
