From 51a0d5a8b6db54368872dc3df9ade204f47c59c7 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 20 Nov 2023 20:10:02 +0000 Subject: Store mutability of bound variables in namespace node --- src/test/java/org/shedlang/compiler/ast/typed/Typed.java | 4 ++-- .../shedlang/compiler/ast/typed/TypedNamespaceNodeMatcher.java | 4 ++-- .../shedlang/compiler/stackir/StackCompilerNamespaceTests.java | 8 ++++---- .../shedlang/compiler/typechecker/TypeCheckerNamespaceTests.java | 6 +++++- 4 files changed, 13 insertions(+), 9 deletions(-) (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/ast/typed/Typed.java b/src/test/java/org/shedlang/compiler/ast/typed/Typed.java index 81958cbe..6ec6c0fb 100644 --- a/src/test/java/org/shedlang/compiler/ast/typed/Typed.java +++ b/src/test/java/org/shedlang/compiler/ast/typed/Typed.java @@ -170,14 +170,14 @@ public class Typed { public static TypedNamespaceNode namespace( NamespaceName namespaceName, List body, - List boundVariableNames, + List boundVariables, List fieldNames ) { return new TypedNamespaceNode( namespaceName, List.of(), body, - boundVariableNames, + boundVariables, fieldNames, Sources.NULL ); diff --git a/src/test/java/org/shedlang/compiler/ast/typed/TypedNamespaceNodeMatcher.java b/src/test/java/org/shedlang/compiler/ast/typed/TypedNamespaceNodeMatcher.java index fbe4a0f9..ae90d3d4 100644 --- a/src/test/java/org/shedlang/compiler/ast/typed/TypedNamespaceNodeMatcher.java +++ b/src/test/java/org/shedlang/compiler/ast/typed/TypedNamespaceNodeMatcher.java @@ -51,10 +51,10 @@ public class TypedNamespaceNodeMatcher implements Matcher { } public Matcher withBoundVariableNames( - Matcher> boundVariableNames + Matcher> boundVariables ) { return new TypedNamespaceNodeMatcher( - submatchers.plus(has("boundVariableNames", x -> x.boundVariableNames(), boundVariableNames)) + submatchers.plus(has("boundVariables", x -> x.boundVariables(), boundVariables)) ); } } diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerNamespaceTests.java b/src/test/java/org/shedlang/compiler/stackir/StackCompilerNamespaceTests.java index e6206b9a..322bf49f 100644 --- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerNamespaceTests.java +++ b/src/test/java/org/shedlang/compiler/stackir/StackCompilerNamespaceTests.java @@ -27,7 +27,7 @@ public class StackCompilerNamespaceTests { .addStatement(Typed.expressionStatement(Typed.stringLiteral("hello"))) .build() ), - List.of("f"), + List.of(BoundVariable.immutable("f")), List.of("f") ); @@ -53,9 +53,9 @@ public class StackCompilerNamespaceTests { public void importsAreLoaded() { var node = TypedNamespaceNode.builder() .addImport(Typed.import_(NamespaceName.of("A"))) - .addBoundVariableName("A") + .addBoundVariable(BoundVariable.immutable("A")) .addImport(Typed.import_(NamespaceName.of("B"))) - .addBoundVariableName("B") + .addBoundVariable(BoundVariable.immutable("B")) .build(); var stackIrNamespace = StackCompiler.compileNamespace(node); @@ -87,7 +87,7 @@ public class StackCompilerNamespaceTests { .withType(structType) .build() ), - List.of("f", "None"), + List.of(BoundVariable.immutable("f"), BoundVariable.immutable("None")), List.of("f", "None") ); diff --git a/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerNamespaceTests.java b/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerNamespaceTests.java index 82ec14f7..65baadce 100644 --- a/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerNamespaceTests.java +++ b/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerNamespaceTests.java @@ -1,6 +1,7 @@ package org.shedlang.compiler.typechecker; import org.junit.jupiter.api.Test; +import org.shedlang.compiler.ast.typed.BoundVariable; import org.shedlang.compiler.ast.untyped.Untyped; import org.shedlang.compiler.ast.untyped.UntypedFunctionDefinitionNode; import org.shedlang.compiler.ast.untyped.UntypedNamespaceNode; @@ -53,7 +54,10 @@ public class TypeCheckerNamespaceTests { isTypedImportNode(NamespaceName.of("A")), isTypedImportNode(NamespaceName.of("B")) )) - .withBoundVariableNames(isSequence(equalTo("A"), equalTo("B"))) + .withBoundVariableNames(isSequence( + equalTo(BoundVariable.immutable("A")), + equalTo(BoundVariable.immutable("B")) + )) ); } -- cgit v1.2.3