summaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserNamespaceTests.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserNamespaceTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserNamespaceTests.java
index ada6414..f749767 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserNamespaceTests.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserNamespaceTests.java
@@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test;
import org.zwobble.hobgoblin.compiler.ast.untyped.UntypedStructDefinitionNode;
import org.zwobble.hobgoblin.compiler.types.NamespaceName;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.zwobble.hobgoblin.compiler.ast.untyped.UntypedImportNodeMatcher.isUntypedImportNode;
import static org.zwobble.hobgoblin.compiler.ast.untyped.UntypedNamespaceNodeMatcher.isUntypedNamespaceNode;
import static org.zwobble.hobgoblin.compiler.parser.ParserTesting.parseString;
@@ -95,4 +96,20 @@ public class ParserNamespaceTests {
))
);
}
+
+ @Test
+ public void whenNamespaceStatementIsNotRecognisedThenErrorIsThrown() {
+ var source = "blah";
+
+ var error = assertThrows(
+ UnexpectedTokenError.class,
+ () -> parseString(
+ source,
+ tokens -> Parser.parseNamespace(tokens, NamespaceName.of("Example", "Project"))
+ )
+ );
+
+ assertThat(error.getExpected(), equalTo("namespace statement"));
+ assertThat(error.getActual().charSequence().toString(), equalTo("blah"));
+ }
}