diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-08-27 20:23:30 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-08-27 20:23:30 +0100 |
| commit | 96de72e5f761eb4bf07536f4dfe282e2e10a2081 (patch) | |
| tree | 4b6a3d3ef1afa9216583ebe13dfd28cad22c2b9c /src/test/java/org/shedlang/compiler/ast | |
| parent | 71fc5352c8c183b91f540ec1134dda24a32ce26c (diff) | |
Add type-checking for while nodes
Diffstat (limited to 'src/test/java/org/shedlang/compiler/ast')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/ast/typed/TypedNodeMatchers.java | 11 | ||||
| -rw-r--r-- | src/test/java/org/shedlang/compiler/ast/untyped/Untyped.java | 7 |
2 files changed, 18 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 9ee8c8fa..5b841f4f 100644 --- a/src/test/java/org/shedlang/compiler/ast/typed/TypedNodeMatchers.java +++ b/src/test/java/org/shedlang/compiler/ast/typed/TypedNodeMatchers.java @@ -259,4 +259,15 @@ public class TypedNodeMatchers { has("expression", x -> x.expression(), expression) ); } + + public static Matcher<TypedFunctionStatementNode> isTypedWhileNode( + Matcher<? super TypedExpressionNode> condition, + Matcher<? super TypedBlockNode> body + ) { + return instanceOf( + TypedWhileNode.class, + has("condition", x -> x.condition(), condition), + has("body", x -> x.body(), body) + ); + } } diff --git a/src/test/java/org/shedlang/compiler/ast/untyped/Untyped.java b/src/test/java/org/shedlang/compiler/ast/untyped/Untyped.java index 1fe48649..753bec1a 100644 --- a/src/test/java/org/shedlang/compiler/ast/untyped/Untyped.java +++ b/src/test/java/org/shedlang/compiler/ast/untyped/Untyped.java @@ -171,4 +171,11 @@ public class Untyped { ) { return new UntypedVarNode(target, expression, Sources.NULL); } + + public static UntypedWhileNode while_( + UntypedExpressionNode condition, + UntypedBlockNode body + ) { + return new UntypedWhileNode(condition, body, Sources.NULL); + } } |
