blob: 3c3b259c51d2f4a93b31612d4d7135500612673f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
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;
public class ParserTableDefinitionTests {
@Test
public void minimalTable() {
var source = """
table posts {
row Post;
primaryKey id;
}""";
var node = parseString(
source,
Parser::parseDatabaseSchemaStatement
);
assertThat(node, isUntypedTableDefinitionNode()
.withName(equalTo("posts"))
.withRowType(isUntypedTypeLevelReferenceNode().withName(equalTo("Post")))
.withPrimaryKey(equalTo("id"))
);
}
}
|