From d52bb965c5f9c2548dfef67cca1b089db26ad71c Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Wed, 7 Jun 2023 20:42:16 +0100 Subject: Parse namespace body --- .../compiler/parser/ParserNamespaceTests.java | 27 +++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/parser/ParserNamespaceTests.java b/src/test/java/org/shedlang/compiler/parser/ParserNamespaceTests.java index 87ebb7e8..15666dc7 100644 --- a/src/test/java/org/shedlang/compiler/parser/ParserNamespaceTests.java +++ b/src/test/java/org/shedlang/compiler/parser/ParserNamespaceTests.java @@ -3,9 +3,10 @@ package org.shedlang.compiler.parser; import org.junit.jupiter.api.Test; import org.shedlang.compiler.ast.UntypedNamespaceNode; +import static org.shedlang.compiler.ast.UntypedNodeMatchers.isUntypedFunctionDefinitionNode; import static org.shedlang.compiler.parser.ParserTesting.parseString; import static org.zwobble.precisely.AssertThat.assertThat; -import static org.zwobble.precisely.Matchers.instanceOf; +import static org.zwobble.precisely.Matchers.*; public class ParserNamespaceTests { @Test @@ -19,4 +20,28 @@ public class ParserNamespaceTests { assertThat(node, instanceOf(UntypedNamespaceNode.class)); } + + @Test + public void canParseNamespaceWithStatements() { + var source = """ + fun f() -> Unit { + } + + fun g() -> Unit { + } + """; + + var node = parseString( + source, + Parser::parseNamespace + ); + + assertThat(node, instanceOf( + UntypedNamespaceNode.class, + has("body", x -> x.body(), isSequence( + isUntypedFunctionDefinitionNode().withName("f"), + isUntypedFunctionDefinitionNode().withName("g") + )) + )); + } } -- cgit v1.2.3