From e4790b25e567aeaef20f29d1a6174413bc8ea0f0 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Wed, 7 Jun 2023 20:09:18 +0100 Subject: Parse body of functions --- .../parser/ParserFunctionDefinitionTests.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/parser/ParserFunctionDefinitionTests.java b/src/test/java/org/shedlang/compiler/parser/ParserFunctionDefinitionTests.java index 80ecb5b2..a05642dc 100644 --- a/src/test/java/org/shedlang/compiler/parser/ParserFunctionDefinitionTests.java +++ b/src/test/java/org/shedlang/compiler/parser/ParserFunctionDefinitionTests.java @@ -26,6 +26,7 @@ public class ParserFunctionDefinitionTests { .withBody(isSequence()) ); } + @Test public void canParseFunctionWithEffect() { var source = """ @@ -40,4 +41,26 @@ public class ParserFunctionDefinitionTests { .withEffect(isOptionalOf(isUntypedTypeLevelReferenceNode("Io"))) ); } + + @Test + public void canParseFunctionWithBody() { + var source = """ + fun f() -> Unit { + a; + b; + c; + }"""; + + var node = parseString(source, Parser::parseNamespaceStatement); + + assertThat( + node, + isUntypedFunctionDefinitionNode() + .withBody(isSequence( + isUntypedExpressionStatementNode(isUntypedReferenceNode("a")), + isUntypedExpressionStatementNode(isUntypedReferenceNode("b")), + isUntypedExpressionStatementNode(isUntypedReferenceNode("c")) + )) + ); + } } -- cgit v1.2.3