aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/shedlang/compiler/ast
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-06-06 19:42:44 +0100
committerMichael Williamson <mike@zwobble.org>2023-06-06 19:42:44 +0100
commit9d66911592c3e3f34aaafdd09c7dd9d96e720e18 (patch)
tree0e033546c49d221163f85d60f52f608a8b8f137e /src/test/java/org/shedlang/compiler/ast
parent7c358460db1c42a5b7e79b7c6706ebf2adcff39f (diff)
Parse call with no effects and no args
Diffstat (limited to 'src/test/java/org/shedlang/compiler/ast')
-rw-r--r--src/test/java/org/shedlang/compiler/ast/UntypedArgsNodeMatcher.java35
-rw-r--r--src/test/java/org/shedlang/compiler/ast/UntypedCallNodeMatcher.java40
-rw-r--r--src/test/java/org/shedlang/compiler/ast/UntypedNodeMatchers.java8
3 files changed, 83 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/ast/UntypedArgsNodeMatcher.java b/src/test/java/org/shedlang/compiler/ast/UntypedArgsNodeMatcher.java
new file mode 100644
index 00000000..315f87d3
--- /dev/null
+++ b/src/test/java/org/shedlang/compiler/ast/UntypedArgsNodeMatcher.java
@@ -0,0 +1,35 @@
+package org.shedlang.compiler.ast;
+
+import org.pcollections.PVector;
+import org.shedlang.compiler.testing.MatcherBuilder;
+import org.zwobble.precisely.Matcher;
+
+import static org.zwobble.precisely.Matchers.has;
+
+public class UntypedArgsNodeMatcher extends MatcherBuilder<UntypedArgsNode, UntypedArgsNode, UntypedArgsNodeMatcher> {
+ public UntypedArgsNodeMatcher() {
+ super();
+ }
+
+ public UntypedArgsNodeMatcher(PVector<Matcher<? super UntypedArgsNode>> submatchers) {
+ super(submatchers);
+ }
+
+ @Override
+ protected Class<UntypedArgsNode> expectedType() {
+ return UntypedArgsNode.class;
+ }
+
+ @Override
+ protected UntypedArgsNodeMatcher create(PVector<Matcher<? super UntypedArgsNode>> submatchers) {
+ return new UntypedArgsNodeMatcher();
+ }
+
+ public UntypedArgsNodeMatcher withPositional(Matcher<? super Iterable<UntypedExpressionNode>> positional) {
+ return with(has("positional", x -> x.positional(), positional));
+ }
+
+ public UntypedArgsNodeMatcher withNamed(Matcher<? super Iterable<UntypedNamedArgNode>> named) {
+ return with(has("named", x -> x.named(), named));
+ }
+}
diff --git a/src/test/java/org/shedlang/compiler/ast/UntypedCallNodeMatcher.java b/src/test/java/org/shedlang/compiler/ast/UntypedCallNodeMatcher.java
new file mode 100644
index 00000000..ef4ad9da
--- /dev/null
+++ b/src/test/java/org/shedlang/compiler/ast/UntypedCallNodeMatcher.java
@@ -0,0 +1,40 @@
+package org.shedlang.compiler.ast;
+
+import org.pcollections.PVector;
+import org.shedlang.compiler.testing.MatcherBuilder;
+import org.zwobble.precisely.Matcher;
+
+import static org.zwobble.precisely.Matchers.equalTo;
+import static org.zwobble.precisely.Matchers.has;
+
+public class UntypedCallNodeMatcher extends MatcherBuilder<UntypedExpressionNode, UntypedCallNode, UntypedCallNodeMatcher> {
+ public UntypedCallNodeMatcher() {
+ super();
+ }
+
+ public UntypedCallNodeMatcher(PVector<Matcher<? super UntypedCallNode>> submatchers) {
+ super(submatchers);
+ }
+
+ @Override
+ protected Class<UntypedCallNode> expectedType() {
+ return UntypedCallNode.class;
+ }
+
+ @Override
+ protected UntypedCallNodeMatcher create(PVector<Matcher<? super UntypedCallNode>> submatchers) {
+ return new UntypedCallNodeMatcher();
+ }
+
+ public UntypedCallNodeMatcher withArgs(Matcher<UntypedArgsNode> args) {
+ return with(has("args", x -> x.args(), args));
+ }
+
+ public UntypedCallNodeMatcher withHasEffects(boolean hasEffects) {
+ return with(has("hasEffects", x -> x.hasEffects(), equalTo(hasEffects)));
+ }
+
+ public UntypedCallNodeMatcher withReceiver(Matcher<UntypedExpressionNode> receiver) {
+ return with(has("receiver", x -> x.receiver(), receiver));
+ }
+}
diff --git a/src/test/java/org/shedlang/compiler/ast/UntypedNodeMatchers.java b/src/test/java/org/shedlang/compiler/ast/UntypedNodeMatchers.java
index 59048782..21e8cf1b 100644
--- a/src/test/java/org/shedlang/compiler/ast/UntypedNodeMatchers.java
+++ b/src/test/java/org/shedlang/compiler/ast/UntypedNodeMatchers.java
@@ -8,6 +8,14 @@ public class UntypedNodeMatchers {
private UntypedNodeMatchers() {
}
+ public static UntypedArgsNodeMatcher isUntypedArgsNode() {
+ return new UntypedArgsNodeMatcher();
+ }
+
+ public static UntypedCallNodeMatcher isUntypedCallNode() {
+ return new UntypedCallNodeMatcher();
+ }
+
public static Matcher<UntypedExpressionNode> isUntypedReferenceNode(String name) {
return instanceOf(
UntypedReferenceNode.class,