summaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-09-27 19:20:17 +0100
committerMichael Williamson <mike@zwobble.org>2026-09-27 19:24:51 +0100
commit275444a59222a078ef65e9458c45d35bfd622745 (patch)
treec685dc245bf49f0140b594321ee3369c1b18790f /src/test/java
parent4ce7b509105e4b14058d61590e58c1e3c902325d (diff)
Parse empty database schema definition
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedDatabaseSchemaDefinitionNodeMatcher.java53
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserDatabaseSchemaDefinitionTests.java27
2 files changed, 80 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedDatabaseSchemaDefinitionNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedDatabaseSchemaDefinitionNodeMatcher.java
new file mode 100644
index 0000000..cb132e0
--- /dev/null
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedDatabaseSchemaDefinitionNodeMatcher.java
@@ -0,0 +1,53 @@
+// Generated by hobgoblin.
+
+package org.zwobble.hobgoblin.compiler.ast.untyped;
+
+// Custom area start: org.zwobble.hobgoblin.compiler.ast.untyped.UntypedDatabaseSchemaDefinitionNodeMatcher imports
+// Custom area end: org.zwobble.hobgoblin.compiler.ast.untyped.UntypedDatabaseSchemaDefinitionNodeMatcher imports
+
+public final class UntypedDatabaseSchemaDefinitionNodeMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> {
+ public static org.zwobble.hobgoblin.compiler.ast.untyped.UntypedDatabaseSchemaDefinitionNodeMatcher isUntypedDatabaseSchemaDefinitionNode() {
+ return new org.zwobble.hobgoblin.compiler.ast.untyped.UntypedDatabaseSchemaDefinitionNodeMatcher(java.util.List.of());
+ }
+
+ private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.untyped.UntypedDatabaseSchemaDefinitionNode>> submatchers;
+
+ private UntypedDatabaseSchemaDefinitionNodeMatcher(
+ java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.untyped.UntypedDatabaseSchemaDefinitionNode>> submatchers
+ ) {
+ this.submatchers = submatchers;
+ }
+
+ public org.zwobble.precisely.MatchResult match(java.lang.Object actual) {
+ return this.toMatcher().match(actual);
+ }
+
+ public org.zwobble.precisely.TextTree describe() {
+ return this.toMatcher().describe();
+ }
+
+ private org.zwobble.precisely.Matcher<java.lang.Object> toMatcher() {
+ return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.ast.untyped.UntypedDatabaseSchemaDefinitionNode.class, this.submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.ast.untyped.UntypedDatabaseSchemaDefinitionNodeMatcher withName(org.zwobble.precisely.Matcher<? super String> name) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.untyped.UntypedDatabaseSchemaDefinitionNode>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.ast.untyped.UntypedDatabaseSchemaDefinitionNode::name, (org.zwobble.precisely.Matcher) name));
+ return new org.zwobble.hobgoblin.compiler.ast.untyped.UntypedDatabaseSchemaDefinitionNodeMatcher(submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.ast.untyped.UntypedDatabaseSchemaDefinitionNodeMatcher 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.UntypedDatabaseSchemaDefinitionNode>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("docComment", org.zwobble.hobgoblin.compiler.ast.untyped.UntypedDatabaseSchemaDefinitionNode::docComment, (org.zwobble.precisely.Matcher) docComment));
+ return new org.zwobble.hobgoblin.compiler.ast.untyped.UntypedDatabaseSchemaDefinitionNodeMatcher(submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.ast.untyped.UntypedDatabaseSchemaDefinitionNodeMatcher withSource(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.sources.Source> source) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.untyped.UntypedDatabaseSchemaDefinitionNode>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("source", org.zwobble.hobgoblin.compiler.ast.untyped.UntypedDatabaseSchemaDefinitionNode::source, (org.zwobble.precisely.Matcher) source));
+ return new org.zwobble.hobgoblin.compiler.ast.untyped.UntypedDatabaseSchemaDefinitionNodeMatcher(submatchers);
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.ast.untyped.UntypedDatabaseSchemaDefinitionNodeMatcher body
+ // Custom area end: org.zwobble.hobgoblin.compiler.ast.untyped.UntypedDatabaseSchemaDefinitionNodeMatcher body
+}
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserDatabaseSchemaDefinitionTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserDatabaseSchemaDefinitionTests.java
new file mode 100644
index 0000000..a43d616
--- /dev/null
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserDatabaseSchemaDefinitionTests.java
@@ -0,0 +1,27 @@
+package org.zwobble.hobgoblin.compiler.parser;
+
+import org.junit.jupiter.api.Test;
+import org.zwobble.hobgoblin.compiler.ast.untyped.UntypedStructDefinitionNode;
+
+import static org.zwobble.hobgoblin.compiler.ast.untyped.UntypedDatabaseSchemaDefinitionNodeMatcher.isUntypedDatabaseSchemaDefinitionNode;
+import static org.zwobble.hobgoblin.compiler.parser.ParserTesting.parseString;
+import static org.zwobble.precisely.AssertThat.assertThat;
+import static org.zwobble.precisely.Matchers.*;
+
+public class ParserDatabaseSchemaDefinitionTests {
+ @Test
+ public void emptySchema() {
+ var source = """
+ databaseSchema BlogApp {
+ }""";
+
+ var node = parseString(
+ source,
+ Parser::parseNamespaceStatement
+ );
+
+ assertThat(node, isUntypedDatabaseSchemaDefinitionNode()
+ .withName(equalTo("BlogApp"))
+ );
+ }
+}