diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-07-08 21:42:45 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-07-08 21:42:45 +0100 |
| commit | cf52b6e8a2ebf85b4be8b9065a755f3481eb43db (patch) | |
| tree | 553f99eee5123f7b06ae34ff657d975adf37b240 /src/test/java/org/shedlang/compiler/ast | |
| parent | b018be7fb57e79b62e727c1fb00bfd474888ddf8 (diff) | |
Parse if expressions
Diffstat (limited to 'src/test/java/org/shedlang/compiler/ast')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java | 22 |
1 files changed, 22 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 bc237a00..17675e35 100644 --- a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java +++ b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java @@ -38,6 +38,17 @@ public class UntypedNodeMatchers { return UntypedCallNodeMatcher.empty(); } + public static Matcher<UntypedConditionalBranchNode> isUntypedConditionalBranchNode( + Matcher<UntypedExpressionNode> condition, + Matcher<Iterable<? extends UntypedFunctionStatementNode>> body + ) { + return instanceOf( + UntypedConditionalBranchNode.class, + has("condition", x -> x.condition(), condition), + has("body", x -> x.body(), body) + ); + } + public static Matcher<UntypedExpressionNode> isUntypedEqualsNode( Matcher<UntypedExpressionNode> left, Matcher<UntypedExpressionNode> right @@ -58,6 +69,17 @@ public class UntypedNodeMatchers { return UntypedFunctionDefinitionNodeMatcher.empty(); } + public static Matcher<UntypedExpressionNode> isUntypedIfNode( + Matcher<Iterable<? extends UntypedConditionalBranchNode>> conditionalBranches, + Matcher<Iterable<? extends UntypedFunctionStatementNode>> elseBody + ) { + return instanceOf( + UntypedIfNode.class, + has("conditionalBranches", x -> x.conditionalBranches(), conditionalBranches), + has("elseBody", x -> x.elseBody(), elseBody) + ); + } + public static Matcher<UntypedExpressionNode> isUntypedIntLiteralNode(int value) { return isUntypedIntLiteralNode(BigInteger.valueOf(value)); } |
