From e1c58cd188df9ba3c5db1ea43e9ec922cc38e2b7 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 14 Jul 2023 21:14:47 +0100 Subject: Check that bodies of if are type checked --- .../compiler/ast/typed/TypedNodeMatchers.java | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (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 fa7fe7ba..8ce4b168 100644 --- a/src/test/java/org/shedlang/compiler/ast/typed/TypedNodeMatchers.java +++ b/src/test/java/org/shedlang/compiler/ast/typed/TypedNodeMatchers.java @@ -1,7 +1,5 @@ package org.shedlang.compiler.ast.typed; -import org.shedlang.compiler.ast.untyped.UntypedBlockNode; -import org.shedlang.compiler.ast.untyped.UntypedFunctionStatementNode; import org.shedlang.compiler.types.Type; import org.shedlang.compiler.types.TypeLevelValue; import org.zwobble.precisely.Matcher; @@ -57,6 +55,16 @@ public class TypedNodeMatchers { return TypedCallNodeMatcher.empty(); } + public static Matcher isTypedConditionalBranchNode( + Matcher condition, + Matcher body + ) { + return allOf( + has("condition", x -> x.condition(), condition), + has("body", x -> x.body(), body) + ); + } + public static Matcher isTypedExpressionStatementNode( Matcher expression ) { @@ -79,6 +87,17 @@ public class TypedNodeMatchers { ); } + public static Matcher isTypedIfNode( + Matcher> conditionalBranches, + Matcher elseBody + ) { + return instanceOf( + TypedIfNode.class, + has("conditionalBranches", x -> x.conditionalBranches(), conditionalBranches), + has("elseBody", x -> x.elseBody(), elseBody) + ); + } + public static Matcher isTypedIntAddNode( Matcher left, Matcher right -- cgit v1.2.3