diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-11-20 20:10:02 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-11-20 20:10:02 +0000 |
| commit | 51a0d5a8b6db54368872dc3df9ade204f47c59c7 (patch) | |
| tree | 10f6640f1f924cb9fea737c122eb0b6268f183a9 /src/test/java | |
| parent | 23c76b64213fbe54dafd5bbf6b9d10efb051d16d (diff) | |
Store mutability of bound variables in namespace node
Diffstat (limited to 'src/test/java')
4 files changed, 13 insertions, 9 deletions
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<TypedNamespaceStatementNode> body, - List<String> boundVariableNames, + List<BoundVariable> boundVariables, List<String> 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<TypedNamespaceNode> { } public Matcher<TypedNamespaceNode> withBoundVariableNames( - Matcher<Iterable<? extends String>> boundVariableNames + Matcher<Iterable<? extends BoundVariable>> 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")) + )) ); } |
