aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/shedlang/compiler/ast
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org/shedlang/compiler/ast')
-rw-r--r--src/test/java/org/shedlang/compiler/ast/typed/TypedNodeMatchers.java4
-rw-r--r--src/test/java/org/shedlang/compiler/ast/typed/TypedStructDefinitionNodeMatcher.java43
2 files changed, 47 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/ast/typed/TypedNodeMatchers.java b/src/test/java/org/shedlang/compiler/ast/typed/TypedNodeMatchers.java
index 52d91cdf..bc5da178 100644
--- a/src/test/java/org/shedlang/compiler/ast/typed/TypedNodeMatchers.java
+++ b/src/test/java/org/shedlang/compiler/ast/typed/TypedNodeMatchers.java
@@ -221,6 +221,10 @@ public class TypedNodeMatchers {
);
}
+ public static TypedStructDefinitionNodeMatcher isTypedStructDefinitionNode() {
+ return TypedStructDefinitionNodeMatcher.empty();
+ }
+
public static Matcher<TypedTargetNode> isTypedTargetIgnore() {
return instanceOf(TypedTargetNode.Ignore.class);
}
diff --git a/src/test/java/org/shedlang/compiler/ast/typed/TypedStructDefinitionNodeMatcher.java b/src/test/java/org/shedlang/compiler/ast/typed/TypedStructDefinitionNodeMatcher.java
new file mode 100644
index 00000000..489fb558
--- /dev/null
+++ b/src/test/java/org/shedlang/compiler/ast/typed/TypedStructDefinitionNodeMatcher.java
@@ -0,0 +1,43 @@
+package org.shedlang.compiler.ast.typed;
+
+import org.pcollections.PVector;
+import org.shedlang.compiler.testing.MatcherBuilder;
+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 TypedStructDefinitionNodeMatcher extends MatcherBuilder<
+ TypedNamespaceStatementNode,
+ TypedStructDefinitionNode,
+ TypedStructDefinitionNodeMatcher
+> {
+ public static TypedStructDefinitionNodeMatcher empty() {
+ return new TypedStructDefinitionNodeMatcher(P.vector());
+ }
+
+ private TypedStructDefinitionNodeMatcher(PVector<Matcher<? super TypedStructDefinitionNode>> submatchers) {
+ super(submatchers);
+ }
+
+ @Override
+ protected Class<TypedStructDefinitionNode> expectedType() {
+ return TypedStructDefinitionNode.class;
+ }
+
+ @Override
+ protected TypedStructDefinitionNodeMatcher create(PVector<Matcher<? super TypedStructDefinitionNode>> submatchers) {
+ return new TypedStructDefinitionNodeMatcher(submatchers);
+ }
+
+ public TypedStructDefinitionNodeMatcher withName(String name) {
+ return with(has("name", x -> x.name(), equalTo(name)));
+ }
+
+ public TypedStructDefinitionNodeMatcher withFields(
+ Matcher<Iterable<? extends TypedStructFieldDefinitionNode>> fields
+ ) {
+ return with(has("fields", x -> x.fields(), fields));
+ }
+}