summaryrefslogtreecommitdiff
path: root/src/test/java/org/zwobble
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org/zwobble')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerStructDefinitionTests.java22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerStructDefinitionTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerStructDefinitionTests.java
index 336c496..8967601 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerStructDefinitionTests.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerStructDefinitionTests.java
@@ -11,10 +11,10 @@ import org.zwobble.hobgoblin.compiler.ast.untyped.UntypedNamespaceNode;
import org.zwobble.hobgoblin.compiler.ast.untyped.UntypedStructDefinitionNode;
import org.zwobble.hobgoblin.compiler.ast.untyped.UntypedStructFieldDefinitionNode;
import org.zwobble.hobgoblin.compiler.sources.NullSource;
+import org.zwobble.hobgoblin.compiler.types.Field;
import org.zwobble.hobgoblin.compiler.types.NamespaceName;
import org.zwobble.hobgoblin.compiler.types.SimpleNativeType;
import org.zwobble.hobgoblin.compiler.types.StructType;
-import org.zwobble.hobgoblin.compiler.types.TypeLevelValueType;
import java.util.List;
@@ -58,13 +58,13 @@ public class TypeCheckerStructDefinitionTests {
DocComment.EMPTY,
NullSource.INSTANCE
);
- var context = TypeCheckerContextArb.namespaceContext(NamespaceName.of("a", "b"));
- context.declare(int32Type.name());
- context.define(int32Type.name(), new TypeLevelValueType(int32Type));
- context.declare(int64Type.name());
- context.define(int64Type.name(), new TypeLevelValueType(int64Type));
+ var globalContext = TypeCheckerGlobalContext.initial();
+ globalContext.addNativeType(int32Type);
+ globalContext.addNativeType(int64Type);
+ var namespaceName = NamespaceName.of("a", "b");
+ var namespaceContext = globalContext.enterNamespace(namespaceName);
- var typed = typeCheckNamespaceStatement(untyped, context);
+ var typed = typeCheckNamespaceStatement(untyped, namespaceContext);
assertThat(typed, instanceOf(
TypedStructDefinitionNode.class,
@@ -91,6 +91,14 @@ public class TypeCheckerStructDefinitionTests {
)
)
));
+ var typesInfo = globalContext.toTypesInfo();
+ assertThat(
+ typesInfo.fieldsOf(new StructType(namespaceName, "X")),
+ isSequence(
+ equalTo(new Field("a", int32Type)),
+ equalTo(new Field("b", int64Type))
+ )
+ );
}
@Test