diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-10-01 17:52:38 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-10-01 17:52:38 +0100 |
| commit | 1dc8b36afbdb164029212d199d225c728c1fa5d9 (patch) | |
| tree | 8b6ee567c95a070d4faeccc55359eaa5e504b7df /src/test/java | |
| parent | c796f48cdf66aafaca202515848422e56aa0ef05 (diff) | |
Extract duplicated typeCheckNamespaceStatement() function
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/typechecker/TypeCheckerTesting.java | 23 |
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); + } +} |
