diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-06-07 20:42:16 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-06-07 20:42:16 +0100 |
| commit | d52bb965c5f9c2548dfef67cca1b089db26ad71c (patch) | |
| tree | aa58f1c114d194fba9f78b2dd1c548b94495a7de /src/test/java | |
| parent | d73f24563db38a46318acf0d4b0378ac787fb593 (diff) | |
Parse namespace body
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/parser/ParserNamespaceTests.java | 27 |
1 files changed, 26 insertions, 1 deletions
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") + )) + )); + } } |
