From 96de72e5f761eb4bf07536f4dfe282e2e10a2081 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 27 Aug 2023 20:23:30 +0100 Subject: Add type-checking for while nodes --- .../org/shedlang/compiler/ast/typed/TypedNodeMatchers.java | 11 +++++++++++ src/test/java/org/shedlang/compiler/ast/untyped/Untyped.java | 7 +++++++ 2 files changed, 18 insertions(+) (limited to 'src/test/java/org/shedlang/compiler/ast') 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 isTypedWhileNode( + Matcher condition, + Matcher 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); + } } -- cgit v1.2.3