From 4564de5f2b387ce71c906d980eb9d9ef2f5c4390 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 10 Jun 2023 19:43:04 +0100 Subject: Add free variables to define function instruction --- .../shedlang/compiler/stackir/StackCompilerFunctionDefinitionTests.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerFunctionDefinitionTests.java b/src/test/java/org/shedlang/compiler/stackir/StackCompilerFunctionDefinitionTests.java index 4e0be235..1fa6c41a 100644 --- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerFunctionDefinitionTests.java +++ b/src/test/java/org/shedlang/compiler/stackir/StackCompilerFunctionDefinitionTests.java @@ -17,6 +17,7 @@ public class StackCompilerFunctionDefinitionTests { .withName("f") .addPositionalParam("x", Typed.typeLevelReference("String", Types.STRING)) .addNamedParam("y", Typed.typeLevelReference("Int", Types.INT)) + .addFreeVariable("z") .addStatement(Typed.expressionStatement(Typed.stringLiteral("hello"))) .build(); @@ -32,6 +33,7 @@ public class StackCompilerFunctionDefinitionTests { has("namedParams", x -> x.namedParams(), isSequence( isDefineFunctionInstructionParam("y") )), + has("freeVariables", x -> x.freeVariables(), containsExactly(equalTo("z"))), has("body", x -> x.body(), isSequence( isPushStringInstruction("hello"), isDiscardInstruction() -- cgit v1.2.3