aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/shedlang/compiler/ast
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-10-22 13:44:07 +0100
committerMichael Williamson <mike@zwobble.org>2023-10-22 13:44:13 +0100
commitbc94a020433c8b7dc0adaa2a6adf235da9c9b4e9 (patch)
tree0c5229feca5ef3a03d1c9321fad3a7531c555d17 /src/test/java/org/shedlang/compiler/ast
parent21a0bdcedd03ac7664bbd3c3fdb5e3ac544a9813 (diff)
Parse visibility for sum type
Diffstat (limited to 'src/test/java/org/shedlang/compiler/ast')
-rw-r--r--src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java11
-rw-r--r--src/test/java/org/shedlang/compiler/ast/untyped/UntypedSumTypeDefinitionNodeMatcher.java52
2 files changed, 54 insertions, 9 deletions
diff --git a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java
index 26716e3d..35e8247a 100644
--- a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java
+++ b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java
@@ -217,15 +217,8 @@ public class UntypedNodeMatchers {
return isUntypedBinaryOperationNode(UntypedBinaryOperator.SUB, left, right);
}
- public static Matcher<UntypedNamespaceStatementNode> isUntypedSumTypeDefinitionNode(
- String name,
- Matcher<Iterable<? extends UntypedTypeLevelExpressionNode>> variants
- ) {
- return instanceOf(
- UntypedSumTypeDefinitionNode.class,
- has("name", x -> x.name(), equalTo(name)),
- has("variants", x -> x.variants(), variants)
- );
+ public static UntypedSumTypeDefinitionNodeMatcher isUntypedSumTypeDefinitionNode() {
+ return UntypedSumTypeDefinitionNodeMatcher.empty();
}
public static Matcher<UntypedTargetNode> isUntypedTargetIgnoreNode() {
diff --git a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedSumTypeDefinitionNodeMatcher.java b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedSumTypeDefinitionNodeMatcher.java
new file mode 100644
index 00000000..aa1ba8d0
--- /dev/null
+++ b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedSumTypeDefinitionNodeMatcher.java
@@ -0,0 +1,52 @@
+package org.shedlang.compiler.ast.untyped;
+
+import org.pcollections.PVector;
+import org.shedlang.compiler.testing.MatcherBuilder;
+import org.shedlang.compiler.types.Visibility;
+import org.shedlang.compiler.util.P;
+import org.zwobble.precisely.Matcher;
+
+import static org.zwobble.precisely.Matchers.equalTo;
+import static org.zwobble.precisely.Matchers.has;
+
+public class UntypedSumTypeDefinitionNodeMatcher extends MatcherBuilder<
+ UntypedNamespaceStatementNode,
+ UntypedSumTypeDefinitionNode,
+ UntypedSumTypeDefinitionNodeMatcher
+> {
+ public static UntypedSumTypeDefinitionNodeMatcher empty() {
+ return new UntypedSumTypeDefinitionNodeMatcher(P.vector());
+ }
+
+ public UntypedSumTypeDefinitionNodeMatcher(
+ PVector<Matcher<? super UntypedSumTypeDefinitionNode>> submatchers
+ ) {
+ super(submatchers);
+ }
+
+ @Override
+ protected Class<UntypedSumTypeDefinitionNode> expectedType() {
+ return UntypedSumTypeDefinitionNode.class;
+ }
+
+ @Override
+ protected UntypedSumTypeDefinitionNodeMatcher create(
+ PVector<Matcher<? super UntypedSumTypeDefinitionNode>> submatchers
+ ) {
+ return new UntypedSumTypeDefinitionNodeMatcher(submatchers);
+ }
+
+ public UntypedSumTypeDefinitionNodeMatcher withName(String name) {
+ return with(has("name", x -> x.name(), equalTo(name)));
+ }
+
+ public UntypedSumTypeDefinitionNodeMatcher withVariants(
+ Matcher<Iterable<? extends UntypedTypeLevelExpressionNode>> variants
+ ) {
+ return with(has("variants", x -> x.variants(), variants));
+ }
+
+ public UntypedSumTypeDefinitionNodeMatcher withVisibility(Visibility visibility) {
+ return with(has("visibility", x -> x.visibility(), equalTo(visibility)));
+ }
+}