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")) ); } }