aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/shedlang/compiler/ast
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-10-25 21:44:51 +0100
committerMichael Williamson <mike@zwobble.org>2023-10-25 21:44:51 +0100
commit5a5e3cad6edd5af97522c99f7b0ffe145d200db0 (patch)
tree92dee5f887b80ad7bb94a723504878c2909e178e /src/test/java/org/shedlang/compiler/ast
parent2cecc44c63d3dbbcc09cb234babde8d849fe04ac (diff)
Introduce UntypedFunctionSignatureNode
Diffstat (limited to 'src/test/java/org/shedlang/compiler/ast')
-rw-r--r--src/test/java/org/shedlang/compiler/ast/untyped/UntypedFunctionDefinitionNodeMatcher.java20
-rw-r--r--src/test/java/org/shedlang/compiler/ast/untyped/UntypedFunctionExpressionNodeMatcher.java20
-rw-r--r--src/test/java/org/shedlang/compiler/ast/untyped/UntypedFunctionSignatureNodeMatcher.java50
-rw-r--r--src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java4
4 files changed, 66 insertions, 28 deletions
diff --git a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedFunctionDefinitionNodeMatcher.java b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedFunctionDefinitionNodeMatcher.java
index f50056f0..d3d1e962 100644
--- a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedFunctionDefinitionNodeMatcher.java
+++ b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedFunctionDefinitionNodeMatcher.java
@@ -6,8 +6,6 @@ import org.shedlang.compiler.testing.MatcherBuilder;
import org.shedlang.compiler.types.Visibility;
import org.zwobble.precisely.Matcher;
-import java.util.Optional;
-
import static org.zwobble.precisely.Matchers.equalTo;
import static org.zwobble.precisely.Matchers.has;
@@ -30,26 +28,20 @@ public class UntypedFunctionDefinitionNodeMatcher extends MatcherBuilder<Untyped
return new UntypedFunctionDefinitionNodeMatcher(submatchers);
}
- public UntypedFunctionDefinitionNodeMatcher withBody(Matcher<UntypedBlockNode> body) {
- return with(has("body", x -> x.body(), body));
+ public UntypedFunctionDefinitionNodeMatcher withSignature(
+ Matcher<? super UntypedFunctionSignatureNode> signature
+ ) {
+ return with(has("signature", x -> x.signature(), signature));
}
- public UntypedFunctionDefinitionNodeMatcher withEffect(Matcher<Optional<? extends UntypedTypeLevelExpressionNode>> effect) {
- return with(has("effect", x -> x.effect(), effect));
+ public UntypedFunctionDefinitionNodeMatcher withBody(Matcher<UntypedBlockNode> body) {
+ return with(has("body", x -> x.body(), body));
}
public UntypedFunctionDefinitionNodeMatcher withName(String name) {
return with(has("name", x -> x.name(), equalTo(name)));
}
- public UntypedFunctionDefinitionNodeMatcher withParams(Matcher<UntypedParamsNode> params) {
- return with(has("params", x -> x.params(), params));
- }
-
- public UntypedFunctionDefinitionNodeMatcher withReturnType(Matcher<UntypedTypeLevelExpressionNode> returnType) {
- return with(has("returnType", x -> x.returnType(), returnType));
- }
-
public UntypedFunctionDefinitionNodeMatcher withVisibility(Visibility visibility) {
return with(has("visibility", x -> x.visibility(), equalTo(visibility)));
}
diff --git a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedFunctionExpressionNodeMatcher.java b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedFunctionExpressionNodeMatcher.java
index f5c8d161..434d79e6 100644
--- a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedFunctionExpressionNodeMatcher.java
+++ b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedFunctionExpressionNodeMatcher.java
@@ -5,8 +5,6 @@ import org.pcollections.PVector;
import org.shedlang.compiler.testing.MatcherBuilder;
import org.zwobble.precisely.Matcher;
-import java.util.Optional;
-
import static org.zwobble.precisely.Matchers.has;
public class UntypedFunctionExpressionNodeMatcher extends MatcherBuilder<
@@ -36,19 +34,13 @@ public class UntypedFunctionExpressionNodeMatcher extends MatcherBuilder<
return new UntypedFunctionExpressionNodeMatcher(submatchers);
}
- public UntypedFunctionExpressionNodeMatcher withBody(Matcher<UntypedBlockNode> body) {
- return with(has("body", x -> x.body(), body));
- }
-
- public UntypedFunctionExpressionNodeMatcher withEffect(Matcher<Optional<? extends UntypedTypeLevelExpressionNode>> effect) {
- return with(has("effect", x -> x.effect(), effect));
- }
-
- public UntypedFunctionExpressionNodeMatcher withParams(Matcher<UntypedParamsNode> params) {
- return with(has("params", x -> x.params(), params));
+ public UntypedFunctionExpressionNodeMatcher withSignature(
+ Matcher<? super UntypedFunctionSignatureNode> signature
+ ) {
+ return with(has("signature", x -> x.signature(), signature));
}
- public UntypedFunctionExpressionNodeMatcher withReturnType(Matcher<UntypedTypeLevelExpressionNode> returnType) {
- return with(has("returnType", x -> x.returnType(), returnType));
+ public UntypedFunctionExpressionNodeMatcher withBody(Matcher<UntypedBlockNode> body) {
+ return with(has("body", x -> x.body(), body));
}
}
diff --git a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedFunctionSignatureNodeMatcher.java b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedFunctionSignatureNodeMatcher.java
new file mode 100644
index 00000000..d799245b
--- /dev/null
+++ b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedFunctionSignatureNodeMatcher.java
@@ -0,0 +1,50 @@
+package org.shedlang.compiler.ast.untyped;
+
+import org.pcollections.Empty;
+import org.pcollections.PVector;
+import org.shedlang.compiler.testing.MatcherBuilder;
+import org.zwobble.precisely.Matcher;
+
+import java.util.Optional;
+
+import static org.zwobble.precisely.Matchers.has;
+
+public class UntypedFunctionSignatureNodeMatcher extends MatcherBuilder<
+ UntypedFunctionSignatureNode,
+ UntypedFunctionSignatureNode,
+ UntypedFunctionSignatureNodeMatcher
+> {
+ public static UntypedFunctionSignatureNodeMatcher empty() {
+ return new UntypedFunctionSignatureNodeMatcher(Empty.vector());
+ }
+
+ public UntypedFunctionSignatureNodeMatcher(
+ PVector<Matcher<? super UntypedFunctionSignatureNode>> submatchers
+ ) {
+ super(submatchers);
+ }
+
+ @Override
+ protected Class<UntypedFunctionSignatureNode> expectedType() {
+ return UntypedFunctionSignatureNode.class;
+ }
+
+ @Override
+ protected UntypedFunctionSignatureNodeMatcher create(
+ PVector<Matcher<? super UntypedFunctionSignatureNode>> submatchers
+ ) {
+ return new UntypedFunctionSignatureNodeMatcher(submatchers);
+ }
+
+ public UntypedFunctionSignatureNodeMatcher withEffect(Matcher<Optional<? extends UntypedTypeLevelExpressionNode>> effect) {
+ return with(has("effect", x -> x.effect(), effect));
+ }
+
+ public UntypedFunctionSignatureNodeMatcher withParams(Matcher<UntypedParamsNode> params) {
+ return with(has("params", x -> x.params(), params));
+ }
+
+ public UntypedFunctionSignatureNodeMatcher withReturnType(Matcher<UntypedTypeLevelExpressionNode> returnType) {
+ return with(has("returnType", x -> x.returnType(), returnType));
+ }
+}
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 0d4940e8..1a7f0611 100644
--- a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java
+++ b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java
@@ -127,6 +127,10 @@ public class UntypedNodeMatchers {
);
}
+ public static UntypedFunctionSignatureNodeMatcher isUntypedFunctionSignatureNode() {
+ return UntypedFunctionSignatureNodeMatcher.empty();
+ }
+
public static UntypedFunctionTypeNodeMatcher isUntypedFunctionTypeNode() {
return UntypedFunctionTypeNodeMatcher.empty();
}