diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-12-26 11:21:15 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-12-26 11:21:15 +0000 |
| commit | 5b1568636d4b6859d0c65f994cfcac32a337f31e (patch) | |
| tree | 25c931c752f6a5169032537b51ac908458e20142 /src/test/java | |
| parent | 086a2d0df252dc55e8ee6607a60e2b754bc785cd (diff) | |
Split out call parsing test
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/parser/ParserCallTests.java | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/src/test/java/org/shedlang/compiler/parser/ParserCallTests.java b/src/test/java/org/shedlang/compiler/parser/ParserCallTests.java index 2e05af17..ca217824 100644 --- a/src/test/java/org/shedlang/compiler/parser/ParserCallTests.java +++ b/src/test/java/org/shedlang/compiler/parser/ParserCallTests.java @@ -10,8 +10,10 @@ import static org.zwobble.precisely.AssertThat.assertThat; import static org.zwobble.precisely.Matchers.isSequence; public class ParserCallTests { + // == Receiver == + @Test - public void canParseCallWithoutEffectsWithNoArguments() { + public void canParseReceiver() { var source = "f()"; var node = parseString(source, Parser::parseTopLevelExpression); @@ -20,12 +22,21 @@ public class ParserCallTests { node, isUntypedCallNode() .withReceiver(isUntypedReferenceNode("f")) + ); + } + + // == Effects == + + @Test + public void canParseCallWithoutEffects() { + var source = "f()"; + + var node = parseString(source, Parser::parseTopLevelExpression); + + assertThat( + node, + isUntypedCallNode() .withHasEffects(false) - .withArgs( - isUntypedArgsNode() - .withPositional(isSequence()) - .withNamed(isSequence()) - ) ); } @@ -42,6 +53,25 @@ public class ParserCallTests { ); } + // == Args == + + @Test + public void canParseCallWithNoArguments() { + var source = "f()"; + + var node = parseString(source, Parser::parseTopLevelExpression); + + assertThat( + node, + isUntypedCallNode() + .withArgs( + isUntypedArgsNode() + .withPositional(isSequence()) + .withNamed(isSequence()) + ) + ); + } + @Test public void canParseCallWithSinglePositionalArg() { var source = "f(a)"; |
