summaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-10-11 20:08:25 +0100
committerMichael Williamson <mike@zwobble.org>2026-10-11 20:08:25 +0100
commit9cbc19c49933411cdd7e57e7c5de9a04314a387c (patch)
treef55f8bb6b2bb3ccce099ba070a5511fcd121edf3 /src/test/java
parent864c5b173a72e269fa6f009c51326c78a042d260 (diff)
Specify row type for tables
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedTableDefinitionNodeMatcher.java6
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserDatabaseSchemaDefinitionTests.java10
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserTableDefinitionTests.java9
3 files changed, 19 insertions, 6 deletions
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedTableDefinitionNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedTableDefinitionNodeMatcher.java
index 4c016a3..8e4226c 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedTableDefinitionNodeMatcher.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedTableDefinitionNodeMatcher.java
@@ -36,6 +36,12 @@ public final class UntypedTableDefinitionNodeMatcher implements org.zwobble.prec
return new org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTableDefinitionNodeMatcher(submatchers);
}
+ public org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTableDefinitionNodeMatcher withRowType(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTypeLevelExpressionNode> rowType) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTableDefinitionNode>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("rowType", org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTableDefinitionNode::rowType, (org.zwobble.precisely.Matcher) rowType));
+ return new org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTableDefinitionNodeMatcher(submatchers);
+ }
+
public org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTableDefinitionNodeMatcher withDocComment(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.DocComment> docComment) {
var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTableDefinitionNode>>(this.submatchers);
submatchers.add(org.zwobble.precisely.Matchers.has("docComment", org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTableDefinitionNode::docComment, (org.zwobble.precisely.Matcher) docComment));
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserDatabaseSchemaDefinitionTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserDatabaseSchemaDefinitionTests.java
index 8241eda..5c41fa1 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserDatabaseSchemaDefinitionTests.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserDatabaseSchemaDefinitionTests.java
@@ -31,10 +31,12 @@ public class ParserDatabaseSchemaDefinitionTests {
public void schemaWithStatements() {
var source = """
databaseSchema BlogApp {
- table Post {
+ table posts {
+ row Post;
}
- table Author {
+ table author {
+ row Author;
}
}""";
@@ -46,8 +48,8 @@ public class ParserDatabaseSchemaDefinitionTests {
assertThat(node, isUntypedDatabaseSchemaDefinitionNode()
.withName(equalTo("BlogApp"))
.withBody(isSequence(
- isUntypedTableDefinitionNode().withName(equalTo("Post")),
- isUntypedTableDefinitionNode().withName(equalTo("Author"))
+ isUntypedTableDefinitionNode().withName(equalTo("posts")),
+ isUntypedTableDefinitionNode().withName(equalTo("author"))
))
);
}
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserTableDefinitionTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserTableDefinitionTests.java
index b39d203..889b30c 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserTableDefinitionTests.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserTableDefinitionTests.java
@@ -3,6 +3,7 @@ package org.zwobble.hobgoblin.compiler.parser;
import org.junit.jupiter.api.Test;
import static org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTableDefinitionNodeMatcher.isUntypedTableDefinitionNode;
+import static org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTypeLevelReferenceNodeMatcher.isUntypedTypeLevelReferenceNode;
import static org.zwobble.hobgoblin.compiler.parser.ParserTesting.parseString;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.equalTo;
@@ -11,7 +12,8 @@ public class ParserTableDefinitionTests {
@Test
public void minimalTable() {
var source = """
- table Post {
+ table posts {
+ row Post;
}""";
var node = parseString(
@@ -19,6 +21,9 @@ public class ParserTableDefinitionTests {
Parser::parseDatabaseSchemaStatement
);
- assertThat(node, isUntypedTableDefinitionNode().withName(equalTo("Post")));
+ assertThat(node, isUntypedTableDefinitionNode()
+ .withName(equalTo("posts"))
+ .withRowType(isUntypedTypeLevelReferenceNode().withName(equalTo("Post")))
+ );
}
}