aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-11-20 19:55:13 +0000
committerMichael Williamson <mike@zwobble.org>2023-11-20 19:55:13 +0000
commit33888c1bac8a1e58fae55f275a0d0eafd16144c5 (patch)
treedb148f62366b4b84fab50f4f6b19ffa5f2e09f05 /src/test/java
parent992336f41a4f6881f2a43e61e479f66e062609fd (diff)
Introduce explicit notion of a BoundVariable
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/shedlang/compiler/ast/typed/Typed.java4
-rw-r--r--src/test/java/org/shedlang/compiler/ast/typed/TypedNodeMatchers.java6
-rw-r--r--src/test/java/org/shedlang/compiler/stackir/StackCompilerValTests.java5
-rw-r--r--src/test/java/org/shedlang/compiler/typechecker/TypeCheckerFunctionBodyTests.java9
-rw-r--r--src/test/java/org/shedlang/compiler/typechecker/TypeCheckerIfTests.java9
5 files changed, 18 insertions, 15 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 717e94d0..81958cbe 100644
--- a/src/test/java/org/shedlang/compiler/ast/typed/Typed.java
+++ b/src/test/java/org/shedlang/compiler/ast/typed/Typed.java
@@ -23,9 +23,9 @@ public class Typed {
public static TypedBlockNode block(
List<TypedFunctionStatementNode> statements,
- List<String> boundVariableNames
+ List<BoundVariable> boundVariables
) {
- return new TypedBlockNode(statements, boundVariableNames, Sources.NULL);
+ return new TypedBlockNode(statements, boundVariables, Sources.NULL);
}
public static TypedBlockReturnNode blockReturn(TypedExpressionNode expression) {
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 faf6f31c..bb787024 100644
--- a/src/test/java/org/shedlang/compiler/ast/typed/TypedNodeMatchers.java
+++ b/src/test/java/org/shedlang/compiler/ast/typed/TypedNodeMatchers.java
@@ -46,10 +46,10 @@ public class TypedNodeMatchers {
return has("statements", x -> x.statements(), statements);
}
- public static Matcher<TypedBlockNode> isTypedBlockNodeWithBoundVariableNames(
- Matcher<Iterable<String>> boundVariableNames
+ public static Matcher<TypedBlockNode> isTypedBlockNodeWithBoundVariables(
+ Matcher<Iterable<BoundVariable>> boundVariables
) {
- return has("boundVariableNames", x -> x.boundVariableNames(), boundVariableNames);
+ return has("boundVariables", x -> x.boundVariables(), boundVariables);
}
public static Matcher<TypedFunctionStatementNode> isTypedBlockReturnNode(
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerValTests.java b/src/test/java/org/shedlang/compiler/stackir/StackCompilerValTests.java
index b72055fd..4d0e1451 100644
--- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerValTests.java
+++ b/src/test/java/org/shedlang/compiler/stackir/StackCompilerValTests.java
@@ -1,6 +1,7 @@
package org.shedlang.compiler.stackir;
import org.junit.jupiter.api.Test;
+import org.shedlang.compiler.ast.typed.BoundVariable;
import org.shedlang.compiler.ast.typed.Typed;
import org.shedlang.compiler.types.Types;
@@ -53,7 +54,7 @@ public class StackCompilerValTests {
Typed.val("x", Typed.intLiteral(11)),
Typed.expressionStatement(Typed.reference("x"))
),
- List.of("x")
+ List.of(BoundVariable.immutable("x"))
)
)
),
@@ -62,7 +63,7 @@ public class StackCompilerValTests {
Typed.val("x", Typed.intLiteral(12)),
Typed.expressionStatement(Typed.reference("x"))
),
- List.of("x")
+ List.of(BoundVariable.immutable("x"))
),
Types.INT
)),
diff --git a/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerFunctionBodyTests.java b/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerFunctionBodyTests.java
index c6abd22a..6ac002b1 100644
--- a/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerFunctionBodyTests.java
+++ b/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerFunctionBodyTests.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.UntypedCallNode;
import org.shedlang.compiler.typechecker.errors.CannotCaptureVarError;
@@ -504,10 +505,10 @@ public class TypeCheckerFunctionBodyTests {
assertThat(
typed.value(),
isTypedFunctionBodyNode()
- .withBlock(isTypedBlockNodeWithBoundVariableNames(containsExactly(
- equalTo("argPositional"),
- equalTo("argNamed"),
- equalTo("local1")
+ .withBlock(isTypedBlockNodeWithBoundVariables(containsExactly(
+ equalTo(BoundVariable.immutable("argPositional")),
+ equalTo(BoundVariable.immutable("argNamed")),
+ equalTo(BoundVariable.immutable("local1"))
)))
);
}
diff --git a/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerIfTests.java b/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerIfTests.java
index 0cbca567..25347042 100644
--- a/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerIfTests.java
+++ b/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerIfTests.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.typechecker.errors.UnexpectedTypeError;
import org.shedlang.compiler.typechecker.typesets.TypeSets;
@@ -176,13 +177,13 @@ public class TypeCheckerIfTests {
isSequence(
isTypedConditionalBranchNode(
anything(),
- isTypedBlockNodeWithBoundVariableNames(containsExactly(
- equalTo("local1")
+ isTypedBlockNodeWithBoundVariables(containsExactly(
+ equalTo(BoundVariable.immutable("local1"))
))
)
),
- isTypedBlockNodeWithBoundVariableNames(containsExactly(
- equalTo("local2")
+ isTypedBlockNodeWithBoundVariables(containsExactly(
+ equalTo(BoundVariable.immutable("local2"))
))
)
);