diff options
| author | Michael Williamson <mike@zwobble.org> | 2024-03-03 10:33:47 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2024-03-03 10:33:47 +0000 |
| commit | 716a7e63392e01dff99111e41c6233655e76e466 (patch) | |
| tree | de0a4c868cf4bfc6fdabac98231504ee0e19d0c7 /src/test/java | |
| parent | f48ecd33ee4430abe7ebb85652554d37d8dea29b (diff) | |
Add type-level args node for more specific source
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/ast/untyped/UntypedCallNodeMatcher.java | 21 | ||||
| -rw-r--r-- | src/test/java/org/shedlang/compiler/parser/ParserCallTests.java | 14 |
2 files changed, 22 insertions, 13 deletions
diff --git a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedCallNodeMatcher.java b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedCallNodeMatcher.java index 3514b522..64cbe0dd 100644 --- a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedCallNodeMatcher.java +++ b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedCallNodeMatcher.java @@ -5,10 +5,7 @@ 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.equalTo; -import static org.zwobble.precisely.Matchers.has; +import static org.zwobble.precisely.Matchers.*; public class UntypedCallNodeMatcher extends MatcherBuilder<UntypedExpressionNode, UntypedCallNode, UntypedCallNodeMatcher> { public static UntypedCallNodeMatcher empty() { @@ -29,10 +26,22 @@ public class UntypedCallNodeMatcher extends MatcherBuilder<UntypedExpressionNode return new UntypedCallNodeMatcher(submatchers); } + public UntypedCallNodeMatcher withoutTypeLevelArgs() { + return with(has("typeLevelArgs", x -> x.typeLevelArgs(), isOptionalEmpty())); + } + public UntypedCallNodeMatcher withTypeLevelArgs( - Matcher<? super Optional<? extends Iterable<? extends UntypedTypeLevelExpressionNode>>> typeLevelArgs + Matcher<? super Iterable<? extends UntypedTypeLevelExpressionNode>> typeLevelArgs ) { - return with(has("typeLevelArgs", x -> x.typeLevelArgs(), typeLevelArgs)); + return with(has( + "typeLevelArgs", + x -> x.typeLevelArgs(), + isOptionalOf(has( + "args", + x -> x.args(), + typeLevelArgs + )) + )); } public UntypedCallNodeMatcher withArgs(Matcher<UntypedArgsNode> args) { diff --git a/src/test/java/org/shedlang/compiler/parser/ParserCallTests.java b/src/test/java/org/shedlang/compiler/parser/ParserCallTests.java index db0cb5de..745c3e7c 100644 --- a/src/test/java/org/shedlang/compiler/parser/ParserCallTests.java +++ b/src/test/java/org/shedlang/compiler/parser/ParserCallTests.java @@ -213,7 +213,7 @@ public class ParserCallTests { assertThat( node, isUntypedCallNode() - .withTypeLevelArgs(isOptionalEmpty()) + .withoutTypeLevelArgs() ); } @@ -226,9 +226,9 @@ public class ParserCallTests { assertThat( node, isUntypedCallNode() - .withTypeLevelArgs(isOptionalOf(isSequence( + .withTypeLevelArgs(isSequence( isUntypedTypeLevelReferenceNode("A") - ))) + )) ); } @@ -241,11 +241,11 @@ public class ParserCallTests { assertThat( node, isUntypedCallNode() - .withTypeLevelArgs(isOptionalOf(isSequence( + .withTypeLevelArgs(isSequence( isUntypedTypeLevelReferenceNode("A"), isUntypedTypeLevelReferenceNode("B"), isUntypedTypeLevelReferenceNode("C") - ))) + )) ); } @@ -258,9 +258,9 @@ public class ParserCallTests { assertThat( node, isUntypedCallNode() - .withTypeLevelArgs(isOptionalOf(isSequence( + .withTypeLevelArgs(isSequence( isUntypedTypeLevelReferenceNode("A") - ))) + )) ); } } |
