aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-10-01 17:52:38 +0100
committerMichael Williamson <mike@zwobble.org>2023-10-01 17:52:38 +0100
commit1dc8b36afbdb164029212d199d225c728c1fa5d9 (patch)
tree8b6ee567c95a070d4faeccc55359eaa5e504b7df /src/test/java
parentc796f48cdf66aafaca202515848422e56aa0ef05 (diff)
Extract duplicated typeCheckNamespaceStatement() function
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/shedlang/compiler/typechecker/TypeCheckerTesting.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerTesting.java b/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerTesting.java
new file mode 100644
index 00000000..e089884f
--- /dev/null
+++ b/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerTesting.java
@@ -0,0 +1,23 @@
+package org.shedlang.compiler.typechecker;
+
+import org.shedlang.compiler.ast.typed.TypedNamespaceStatementNode;
+import org.shedlang.compiler.ast.untyped.UntypedNamespaceStatementNode;
+import org.shedlang.compiler.types.NamespaceName;
+import org.shedlang.compiler.util.P;
+
+public class TypeCheckerTesting {
+ private TypeCheckerTesting() {
+ }
+
+ static TypeCheckerResult<? extends TypedNamespaceStatementNode> typeCheckNamespaceStatement(
+ UntypedNamespaceStatementNode untyped,
+ TypeCheckerContext context
+ ) {
+ var declaredVariables = DeclaredVariables.forNamespaceStatement(untyped, P.vector());
+ var environment = EnvironmentBuilder.EMPTY.addUndefined(declaredVariables);
+
+ context = context.enterNamespace(NamespaceName.of("Example"), environment.build());
+
+ return TypeChecker.typeCheckStepsNamespaceStatement(untyped).typeCheckAllPhases(context);
+ }
+}