aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-09-28 14:21:12 +0100
committerMichael Williamson <mike@zwobble.org>2023-09-28 14:21:12 +0100
commit862359008799b4038c32d909cd31808421e60739 (patch)
treee38320c972825deac796ef13d80d592d62709e2c /src/test/java
parent8bcc629a7c6d7d30b403c0a13ee032e7e75298e8 (diff)
Store struct type instead of name in typed struct definition node
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/shedlang/compiler/ast/typed/TypedStructDefinitionNodeMatcher.java6
-rw-r--r--src/test/java/org/shedlang/compiler/typechecker/TypeCheckerNamespaceTests.java10
-rw-r--r--src/test/java/org/shedlang/compiler/typechecker/TypeCheckerStructDefinitionTests.java5
3 files changed, 12 insertions, 9 deletions
diff --git a/src/test/java/org/shedlang/compiler/ast/typed/TypedStructDefinitionNodeMatcher.java b/src/test/java/org/shedlang/compiler/ast/typed/TypedStructDefinitionNodeMatcher.java
index 489fb558..b80aff1d 100644
--- a/src/test/java/org/shedlang/compiler/ast/typed/TypedStructDefinitionNodeMatcher.java
+++ b/src/test/java/org/shedlang/compiler/ast/typed/TypedStructDefinitionNodeMatcher.java
@@ -2,10 +2,10 @@ package org.shedlang.compiler.ast.typed;
import org.pcollections.PVector;
import org.shedlang.compiler.testing.MatcherBuilder;
+import org.shedlang.compiler.types.StructType;
import org.shedlang.compiler.util.P;
import org.zwobble.precisely.Matcher;
-import static org.zwobble.precisely.Matchers.equalTo;
import static org.zwobble.precisely.Matchers.has;
public class TypedStructDefinitionNodeMatcher extends MatcherBuilder<
@@ -31,8 +31,8 @@ public class TypedStructDefinitionNodeMatcher extends MatcherBuilder<
return new TypedStructDefinitionNodeMatcher(submatchers);
}
- public TypedStructDefinitionNodeMatcher withName(String name) {
- return with(has("name", x -> x.name(), equalTo(name)));
+ public TypedStructDefinitionNodeMatcher withType(Matcher<? super StructType> type) {
+ return with(has("type", x -> x.type(), type));
}
public TypedStructDefinitionNodeMatcher withFields(
diff --git a/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerNamespaceTests.java b/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerNamespaceTests.java
index 226769bf..2c4f844d 100644
--- a/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerNamespaceTests.java
+++ b/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerNamespaceTests.java
@@ -306,7 +306,8 @@ public class TypeCheckerNamespaceTests {
result.value(),
isTypedNamespaceNode()
.withBody(isSequence(
- isTypedStructDefinitionNode().withName("User"),
+ isTypedStructDefinitionNode()
+ .withType(isStructType(NamespaceName.of("Example", "Project"), "User")),
isTypedFunctionDefinitionNode()
.withName("printUser")
.withParams(isTypedParamsNode(
@@ -356,7 +357,8 @@ public class TypeCheckerNamespaceTests {
)),
isSequence()
)),
- isTypedStructDefinitionNode().withName("User")
+ isTypedStructDefinitionNode()
+ .withType(isStructType(NamespaceName.of("Example", "Project"), "User"))
))
);
}
@@ -416,14 +418,14 @@ public class TypeCheckerNamespaceTests {
isTypedNamespaceNode()
.withBody(isSequence(
isTypedStructDefinitionNode()
- .withName("A")
+ .withType(isStructType(NamespaceName.of("Example", "Project"), "A"))
.withFields(isSequence(
isTypedStructFieldDefinitionNode()
.withName("b")
.withType(isTypedTypeLevelExpressionNode(Types.struct(namespaceName, "B")))
)),
isTypedStructDefinitionNode()
- .withName("B")
+ .withType(isStructType(NamespaceName.of("Example", "Project"), "B"))
.withFields(isSequence(
isTypedStructFieldDefinitionNode()
.withName("a")
diff --git a/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerStructDefinitionTests.java b/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerStructDefinitionTests.java
index e8628411..a0efeac3 100644
--- a/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerStructDefinitionTests.java
+++ b/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerStructDefinitionTests.java
@@ -14,6 +14,7 @@ import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.shedlang.compiler.ast.typed.TypedNodeMatchers.*;
+import static org.shedlang.compiler.types.TypeMatchers.isStructType;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.*;
@@ -45,7 +46,7 @@ public class TypeCheckerStructDefinitionTests {
assertThat(
typed.value(),
isTypedStructDefinitionNode()
- .withName("ExampleStruct")
+ .withType(isStructType(NAMESPACE_NAME, "ExampleStruct"))
.withFields(isSequence())
);
}
@@ -86,7 +87,7 @@ public class TypeCheckerStructDefinitionTests {
assertThat(
typed.value(),
isTypedStructDefinitionNode()
- .withName("ExampleStruct")
+ .withType(isStructType(NAMESPACE_NAME, "ExampleStruct"))
.withFields(isSequence(
isTypedStructFieldDefinitionNode()
.withName("b")