summaryrefslogtreecommitdiff
path: root/src/test/java/org/zwobble
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-08-09 16:53:54 +0100
committerMichael Williamson <mike@zwobble.org>2026-08-09 16:53:54 +0100
commit9105526554dc825095c02fdafb1fb7d1852aa134 (patch)
tree655558bbafa8f0554e62d61210600df9b81b99c8 /src/test/java/org/zwobble
parentb6008e5942036c8ebc258a62fc241760e2db9c1a (diff)
Add params to type aliases in Rust AST
Diffstat (limited to 'src/test/java/org/zwobble')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriterTests.java14
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypeAliasMatcher.java6
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypeParamMatcher.java41
3 files changed, 61 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 f06b4a1..5b1fe95 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
@@ -121,6 +121,20 @@ public class RustWriterTests {
assertThat(string, equalTo("type X = Y;"));
}
+ @Test
+ public void typeAliasWithUnboundedTypeParam() throws IOException {
+ var rust = RustTypeAlias.arbitrary()
+ .withName(RustIdentifier.of("X"))
+ .addParam(RustTypeParam.arbitrary().withName(RustIdentifier.of("T1")))
+ .addParam(RustTypeParam.arbitrary().withName(RustIdentifier.of("T2")))
+ .withType(RustPath.of("Y"))
+ .build();
+
+ var string = write(writer -> writer.writeItem(rust));
+
+ assertThat(string, equalTo("type X<T1, T2> = Y;"));
+ }
+
// === Structs ===
@Test
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypeAliasMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypeAliasMatcher.java
index 8cabb97..41ff267 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypeAliasMatcher.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypeAliasMatcher.java
@@ -36,6 +36,12 @@ public final class RustTypeAliasMatcher implements org.zwobble.precisely.Matcher
return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeAliasMatcher(submatchers);
}
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeAliasMatcher withParams(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeParam>> params) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeAlias>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("params", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeAlias::params, params));
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeAliasMatcher(submatchers);
+ }
+
public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeAliasMatcher withType(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType> type) {
var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeAlias>>(this.submatchers);
submatchers.add(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeAlias::type, type));
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypeParamMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypeParamMatcher.java
new file mode 100644
index 0000000..99e09bc
--- /dev/null
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypeParamMatcher.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.RustTypeParamMatcher imports
+// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeParamMatcher imports
+
+public final class RustTypeParamMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> {
+ public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeParamMatcher isRustTypeParam() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeParamMatcher(java.util.List.of());
+ }
+
+ private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeParam>> submatchers;
+
+ private RustTypeParamMatcher(
+ java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeParam>> 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.RustTypeParam.class, this.submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeParamMatcher withName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustIdentifier> name) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeParam>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeParam::name, name));
+ return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeParamMatcher(submatchers);
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeParamMatcher body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypeParamMatcher body
+}