From 73fd8c4a3d9f593ed2a5394a5b34b88a27938e27 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 27 Sep 2026 19:49:22 +0100 Subject: Define typed AST in hobgoblin --- .../ast/typed/TypedEnumDefinitionNodeMatcher.java | 59 ++++++++++++++++++++ .../TypedEnumVariantDefinitionNodeMatcher.java | 47 ++++++++++++++++ .../ast/typed/TypedNamespaceNodeMatcher.java | 53 ++++++++++++++++++ .../TypedNativeTypeDefinitionNodeMatcher.java | 53 ++++++++++++++++++ .../typed/TypedStructDefinitionNodeMatcher.java | 59 ++++++++++++++++++++ .../TypedStructFieldDefinitionNodeMatcher.java | 53 ++++++++++++++++++ .../ast/typed/TypedSumDefinitionNodeMatcher.java | 65 ++++++++++++++++++++++ .../TypedSumVariantDefinitionNodeMatcher.java | 47 ++++++++++++++++ .../TypeCheckerStructDefinitionTests.java | 37 ++---------- .../typechecker/TypeCheckerSumDefinitionTests.java | 37 ++---------- 10 files changed, 448 insertions(+), 62 deletions(-) create mode 100644 src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumDefinitionNodeMatcher.java create mode 100644 src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumVariantDefinitionNodeMatcher.java create mode 100644 src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNamespaceNodeMatcher.java create mode 100644 src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNativeTypeDefinitionNodeMatcher.java create mode 100644 src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructDefinitionNodeMatcher.java create mode 100644 src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructFieldDefinitionNodeMatcher.java create mode 100644 src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumDefinitionNodeMatcher.java create mode 100644 src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumVariantDefinitionNodeMatcher.java (limited to 'src/test/java') diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumDefinitionNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumDefinitionNodeMatcher.java new file mode 100644 index 0000000..3839c4a --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumDefinitionNodeMatcher.java @@ -0,0 +1,59 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.ast.typed; + +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher imports + +public final class TypedEnumDefinitionNodeMatcher implements org.zwobble.precisely.Matcher { + public static org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher isTypedEnumDefinitionNode() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher(java.util.List.of()); + } + + private final java.util.List> submatchers; + + private TypedEnumDefinitionNodeMatcher( + java.util.List> 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 toMatcher() { + return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher withType(org.zwobble.precisely.Matcher type) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode::type, (org.zwobble.precisely.Matcher) type)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher withVariants(org.zwobble.precisely.Matcher> variants) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("variants", org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode::variants, (org.zwobble.precisely.Matcher) variants)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher withDocComment(org.zwobble.precisely.Matcher docComment) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("docComment", org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode::docComment, (org.zwobble.precisely.Matcher) docComment)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher withSource(org.zwobble.precisely.Matcher source) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("source", org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode::source, (org.zwobble.precisely.Matcher) source)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumVariantDefinitionNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumVariantDefinitionNodeMatcher.java new file mode 100644 index 0000000..5d3822d --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumVariantDefinitionNodeMatcher.java @@ -0,0 +1,47 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.ast.typed; + +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNodeMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNodeMatcher imports + +public final class TypedEnumVariantDefinitionNodeMatcher implements org.zwobble.precisely.Matcher { + public static org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNodeMatcher isTypedEnumVariantDefinitionNode() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNodeMatcher(java.util.List.of()); + } + + private final java.util.List> submatchers; + + private TypedEnumVariantDefinitionNodeMatcher( + java.util.List> 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 toMatcher() { + return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNodeMatcher withName(org.zwobble.precisely.Matcher name) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode::name, (org.zwobble.precisely.Matcher) name)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNodeMatcher withSource(org.zwobble.precisely.Matcher source) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("source", org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode::source, (org.zwobble.precisely.Matcher) source)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNodeMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNodeMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNodeMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNamespaceNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNamespaceNodeMatcher.java new file mode 100644 index 0000000..2b19bd0 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNamespaceNodeMatcher.java @@ -0,0 +1,53 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.ast.typed; + +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher imports + +public final class TypedNamespaceNodeMatcher implements org.zwobble.precisely.Matcher { + public static org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher isTypedNamespaceNode() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher(java.util.List.of()); + } + + private final java.util.List> submatchers; + + private TypedNamespaceNodeMatcher( + java.util.List> 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 toMatcher() { + return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher withNamespaceName(org.zwobble.precisely.Matcher namespaceName) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("namespaceName", org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode::namespaceName, (org.zwobble.precisely.Matcher) namespaceName)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher withBody(org.zwobble.precisely.Matcher> body) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("body", org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode::body, (org.zwobble.precisely.Matcher) body)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher withSource(org.zwobble.precisely.Matcher source) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("source", org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode::source, (org.zwobble.precisely.Matcher) source)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNativeTypeDefinitionNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNativeTypeDefinitionNodeMatcher.java new file mode 100644 index 0000000..c9c96ff --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNativeTypeDefinitionNodeMatcher.java @@ -0,0 +1,53 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.ast.typed; + +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher imports + +public final class TypedNativeTypeDefinitionNodeMatcher implements org.zwobble.precisely.Matcher { + public static org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher isTypedNativeTypeDefinitionNode() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher(java.util.List.of()); + } + + private final java.util.List> submatchers; + + private TypedNativeTypeDefinitionNodeMatcher( + java.util.List> 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 toMatcher() { + return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher withTypeOrConstructor(org.zwobble.precisely.Matcher> typeOrConstructor) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("typeOrConstructor", org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode::typeOrConstructor, (org.zwobble.precisely.Matcher) typeOrConstructor)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher withDocComment(org.zwobble.precisely.Matcher docComment) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("docComment", org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode::docComment, (org.zwobble.precisely.Matcher) docComment)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher withSource(org.zwobble.precisely.Matcher source) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("source", org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode::source, (org.zwobble.precisely.Matcher) source)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructDefinitionNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructDefinitionNodeMatcher.java new file mode 100644 index 0000000..e9f44bd --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructDefinitionNodeMatcher.java @@ -0,0 +1,59 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.ast.typed; + +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher imports + +public final class TypedStructDefinitionNodeMatcher implements org.zwobble.precisely.Matcher { + public static org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher isTypedStructDefinitionNode() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher(java.util.List.of()); + } + + private final java.util.List> submatchers; + + private TypedStructDefinitionNodeMatcher( + java.util.List> 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 toMatcher() { + return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher withTypeOrConstructor(org.zwobble.precisely.Matcher> typeOrConstructor) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("typeOrConstructor", org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode::typeOrConstructor, (org.zwobble.precisely.Matcher) typeOrConstructor)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher withFields(org.zwobble.precisely.Matcher>> fields) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("fields", org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode::fields, (org.zwobble.precisely.Matcher) fields)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher withDocComment(org.zwobble.precisely.Matcher docComment) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("docComment", org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode::docComment, (org.zwobble.precisely.Matcher) docComment)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher withSource(org.zwobble.precisely.Matcher source) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("source", org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode::source, (org.zwobble.precisely.Matcher) source)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructFieldDefinitionNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructFieldDefinitionNodeMatcher.java new file mode 100644 index 0000000..11760f9 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructFieldDefinitionNodeMatcher.java @@ -0,0 +1,53 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.ast.typed; + +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher imports + +public final class TypedStructFieldDefinitionNodeMatcher implements org.zwobble.precisely.Matcher { + public static org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher isTypedStructFieldDefinitionNode() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher(java.util.List.of()); + } + + private final java.util.List> submatchers; + + private TypedStructFieldDefinitionNodeMatcher( + java.util.List> 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 toMatcher() { + return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher withName(org.zwobble.precisely.Matcher name) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode::name, (org.zwobble.precisely.Matcher) name)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher withType(org.zwobble.precisely.Matcher type) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode::type, (org.zwobble.precisely.Matcher) type)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher withSource(org.zwobble.precisely.Matcher source) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("source", org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode::source, (org.zwobble.precisely.Matcher) source)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumDefinitionNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumDefinitionNodeMatcher.java new file mode 100644 index 0000000..d52472a --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumDefinitionNodeMatcher.java @@ -0,0 +1,65 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.ast.typed; + +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher imports + +public final class TypedSumDefinitionNodeMatcher implements org.zwobble.precisely.Matcher { + public static org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher isTypedSumDefinitionNode() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher(java.util.List.of()); + } + + private final java.util.List> submatchers; + + private TypedSumDefinitionNodeMatcher( + java.util.List> 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 toMatcher() { + return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher withType(org.zwobble.precisely.Matcher type) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode::type, (org.zwobble.precisely.Matcher) type)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher withVariants(org.zwobble.precisely.Matcher> variants) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("variants", org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode::variants, (org.zwobble.precisely.Matcher) variants)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher withFields(org.zwobble.precisely.Matcher> fields) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("fields", org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode::fields, (org.zwobble.precisely.Matcher) fields)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher withDocComment(org.zwobble.precisely.Matcher docComment) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("docComment", org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode::docComment, (org.zwobble.precisely.Matcher) docComment)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher withSource(org.zwobble.precisely.Matcher source) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("source", org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode::source, (org.zwobble.precisely.Matcher) source)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumVariantDefinitionNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumVariantDefinitionNodeMatcher.java new file mode 100644 index 0000000..25d2051 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumVariantDefinitionNodeMatcher.java @@ -0,0 +1,47 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.ast.typed; + +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNodeMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNodeMatcher imports + +public final class TypedSumVariantDefinitionNodeMatcher implements org.zwobble.precisely.Matcher { + public static org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNodeMatcher isTypedSumVariantDefinitionNode() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNodeMatcher(java.util.List.of()); + } + + private final java.util.List> submatchers; + + private TypedSumVariantDefinitionNodeMatcher( + java.util.List> 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 toMatcher() { + return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNodeMatcher withType(org.zwobble.precisely.Matcher type) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode::type, (org.zwobble.precisely.Matcher) type)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNodeMatcher withSource(org.zwobble.precisely.Matcher source) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("source", org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode::source, (org.zwobble.precisely.Matcher) source)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNodeMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNodeMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNodeMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerStructDefinitionTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerStructDefinitionTests.java index fa913fa..f25a600 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerStructDefinitionTests.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerStructDefinitionTests.java @@ -4,7 +4,6 @@ import org.junit.jupiter.api.Test; import org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode; import org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode; import org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode; -import org.zwobble.hobgoblin.compiler.ast.typed.TypedTypeLevelExpressionNode; import org.zwobble.hobgoblin.compiler.ast.untyped.*; import org.zwobble.hobgoblin.compiler.typechecker.errors.SingletonStructCannotHaveTypeParamsError; import org.zwobble.hobgoblin.compiler.types.*; @@ -104,19 +103,11 @@ public class TypeCheckerStructDefinitionTests { isOptionalOf(isSequence( allOf( has("name", TypedStructFieldDefinitionNode::name, equalTo("a")), - has("type", TypedStructFieldDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(int32Type) - )) + has("type", TypedStructFieldDefinitionNode::type, equalTo(int32Type)) ), allOf( has("name", TypedStructFieldDefinitionNode::name, equalTo("b")), - has("type", TypedStructFieldDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(int64Type) - )) + has("type", TypedStructFieldDefinitionNode::type, equalTo(int64Type)) ) )) ) @@ -209,19 +200,11 @@ public class TypeCheckerStructDefinitionTests { isOptionalOf(isSequence( allOf( has("name", TypedStructFieldDefinitionNode::name, equalTo("a")), - has("type", TypedStructFieldDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(new TypeParam(expectedInnerType, "A")) - )) + has("type", TypedStructFieldDefinitionNode::type, equalTo(new TypeParam(expectedInnerType, "A"))) ), allOf( has("name", TypedStructFieldDefinitionNode::name, equalTo("b")), - has("type", TypedStructFieldDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(new TypeParam(expectedInnerType, "B")) - )) + has("type", TypedStructFieldDefinitionNode::type, equalTo(new TypeParam(expectedInnerType, "B"))) ) )) ) @@ -275,11 +258,7 @@ public class TypeCheckerStructDefinitionTests { isOptionalOf(isSequence( allOf( has("name", TypedStructFieldDefinitionNode::name, equalTo("value")), - has("type", TypedStructFieldDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(new SimpleStructType(namespaceName, "Y")) - )) + has("type", TypedStructFieldDefinitionNode::type, equalTo(new SimpleStructType(namespaceName, "Y"))) ) )) ) @@ -293,11 +272,7 @@ public class TypeCheckerStructDefinitionTests { isOptionalOf(isSequence( allOf( has("name", TypedStructFieldDefinitionNode::name, equalTo("value")), - has("type", TypedStructFieldDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(int32Type) - )) + has("type", TypedStructFieldDefinitionNode::type, equalTo(int32Type)) ) )) ) diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerSumDefinitionTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerSumDefinitionTests.java index 693f2fa..a1cb5a9 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerSumDefinitionTests.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerSumDefinitionTests.java @@ -4,7 +4,6 @@ import org.junit.jupiter.api.Test; import org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode; import org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode; import org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode; -import org.zwobble.hobgoblin.compiler.ast.typed.TypedTypeLevelExpressionNode; import org.zwobble.hobgoblin.compiler.ast.untyped.*; import org.zwobble.hobgoblin.compiler.builtins.NativeTypes; import org.zwobble.hobgoblin.compiler.sources.NullSource; @@ -67,16 +66,8 @@ public class TypeCheckerSumDefinitionTests { "variants", TypedSumDefinitionNode::variants, isSequence( - has("type", TypedSumVariantDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(rectangleType) - )), - has("type", TypedSumVariantDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(triangleType) - )) + has("type", TypedSumVariantDefinitionNode::type, equalTo(rectangleType)), + has("type", TypedSumVariantDefinitionNode::type, equalTo(triangleType)) ) ) )); @@ -124,16 +115,8 @@ public class TypeCheckerSumDefinitionTests { "variants", TypedSumDefinitionNode::variants, isSequence( - has("type", TypedSumVariantDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(NativeTypes.box(rectangleType)) - )), - has("type", TypedSumVariantDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(triangleType) - )) + has("type", TypedSumVariantDefinitionNode::type, equalTo(NativeTypes.box(rectangleType))), + has("type", TypedSumVariantDefinitionNode::type, equalTo(triangleType)) ) ) )); @@ -232,19 +215,11 @@ public class TypeCheckerSumDefinitionTests { isSequence( allOf( has("name", TypedStructFieldDefinitionNode::name, equalTo("x")), - has("type", TypedStructFieldDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(int32Type) - )) + has("type", TypedStructFieldDefinitionNode::type, equalTo(int32Type)) ), allOf( has("name", TypedStructFieldDefinitionNode::name, equalTo("y")), - has("type", TypedStructFieldDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(int64Type) - )) + has("type", TypedStructFieldDefinitionNode::type, equalTo(int64Type)) ) ) ) -- cgit v1.2.3