diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-09-27 20:28:09 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-09-27 20:28:09 +0100 |
| commit | 059d6276a4d2ef23672adb009e633a06f3603a8c (patch) | |
| tree | 162ba95c15b2ed66c323be4c2225c4b096313dfc /src/test/java/org/shedlang/compiler/ast | |
| parent | a0074f328bfabc0c28d7e5b1202761daaa265fc8 (diff) | |
Parse struct definition fields
Diffstat (limited to 'src/test/java/org/shedlang/compiler/ast')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java | 4 | ||||
| -rw-r--r-- | src/test/java/org/shedlang/compiler/ast/untyped/UntypedStructFieldDefinitionNodeMatcher.java | 37 |
2 files changed, 41 insertions, 0 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 95d666cd..d08e784d 100644 --- a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java +++ b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java @@ -198,6 +198,10 @@ public class UntypedNodeMatchers { return UntypedStructDefinitionNodeMatcher.empty(); } + public static UntypedStructFieldDefinitionNodeMatcher isUntypedStructFieldDefinitionNode() { + return UntypedStructFieldDefinitionNodeMatcher.empty(); + } + public static Matcher<UntypedExpressionNode> isUntypedSubNode( Matcher<UntypedExpressionNode> left, Matcher<UntypedExpressionNode> right diff --git a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedStructFieldDefinitionNodeMatcher.java b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedStructFieldDefinitionNodeMatcher.java new file mode 100644 index 00000000..2e0f1d63 --- /dev/null +++ b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedStructFieldDefinitionNodeMatcher.java @@ -0,0 +1,37 @@ +package org.shedlang.compiler.ast.untyped; + +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 UntypedStructFieldDefinitionNodeMatcher extends MatcherBuilder<UntypedStructFieldDefinitionNode, UntypedStructFieldDefinitionNode, UntypedStructFieldDefinitionNodeMatcher> { + public static UntypedStructFieldDefinitionNodeMatcher empty() { + return new UntypedStructFieldDefinitionNodeMatcher(P.vector()); + } + + public UntypedStructFieldDefinitionNodeMatcher(PVector<Matcher<? super UntypedStructFieldDefinitionNode>> submatchers) { + super(submatchers); + } + + @Override + protected Class<UntypedStructFieldDefinitionNode> expectedType() { + return UntypedStructFieldDefinitionNode.class; + } + + @Override + protected UntypedStructFieldDefinitionNodeMatcher create(PVector<Matcher<? super UntypedStructFieldDefinitionNode>> submatchers) { + return new UntypedStructFieldDefinitionNodeMatcher(submatchers); + } + + public UntypedStructFieldDefinitionNodeMatcher withName(String name) { + return with(has("name", x -> x.name(), equalTo(name))); + } + + public UntypedStructFieldDefinitionNodeMatcher withType(Matcher<UntypedTypeLevelExpressionNode> type) { + return with(has("type", x -> x.type(), type)); + } +} |
