From 74b9cec87c2d5958cf2076396fa0cbb5ae1e6e02 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 17 Jun 2023 21:36:45 +0100 Subject: Create FreeVariable type with index and name --- .../compiler/ast/typed/TypedFunctionDefinitionNodeMatcher.java | 2 +- .../compiler/stackir/StackCompilerFunctionDefinitionTests.java | 4 +++- .../compiler/typechecker/TypeCheckerFunctionDefinitionTests.java | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/ast/typed/TypedFunctionDefinitionNodeMatcher.java b/src/test/java/org/shedlang/compiler/ast/typed/TypedFunctionDefinitionNodeMatcher.java index c1d047af..0d4f4cfa 100644 --- a/src/test/java/org/shedlang/compiler/ast/typed/TypedFunctionDefinitionNodeMatcher.java +++ b/src/test/java/org/shedlang/compiler/ast/typed/TypedFunctionDefinitionNodeMatcher.java @@ -38,7 +38,7 @@ public class TypedFunctionDefinitionNodeMatcher extends MatcherBuilder x.effect(), effect)); } - public TypedFunctionDefinitionNodeMatcher withFreeVariables(Matcher> freeVariables) { + public TypedFunctionDefinitionNodeMatcher withFreeVariables(Matcher> freeVariables) { return with(has("freeVariables", x -> x.freeVariables(), freeVariables)); } diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerFunctionDefinitionTests.java b/src/test/java/org/shedlang/compiler/stackir/StackCompilerFunctionDefinitionTests.java index 05063961..28974ea9 100644 --- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerFunctionDefinitionTests.java +++ b/src/test/java/org/shedlang/compiler/stackir/StackCompilerFunctionDefinitionTests.java @@ -33,7 +33,9 @@ public class StackCompilerFunctionDefinitionTests { has("namedParams", x -> x.namedParams(), isSequence( isDefineFunctionInstructionParam("y") )), - has("freeVariables", x -> x.freeVariables(), containsExactly(equalTo("z"))), + has("freeVariables", x -> x.freeVariables(), containsExactly( + has("name", x -> x.name(), equalTo("z")) + )), has("body", x -> x.body(), isSequence( isPushStringInstruction("hello"), isDiscardInstruction(), diff --git a/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerFunctionDefinitionTests.java b/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerFunctionDefinitionTests.java index f3cbf0fe..26ea2693 100644 --- a/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerFunctionDefinitionTests.java +++ b/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerFunctionDefinitionTests.java @@ -179,7 +179,9 @@ public class TypeCheckerFunctionDefinitionTests { assertThat( typed, isTypedFunctionDefinitionNode() - .withFreeVariables(containsExactly(equalTo("y"))) + .withFreeVariables(containsExactly( + has("name", x -> x.name(), equalTo("y")) + )) ); } -- cgit v1.2.3