aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/shedlang/compiler/parser/ParserCallTests.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/parser/ParserCallTests.java b/src/test/java/org/shedlang/compiler/parser/ParserCallTests.java
index 1020b430..d75c6643 100644
--- a/src/test/java/org/shedlang/compiler/parser/ParserCallTests.java
+++ b/src/test/java/org/shedlang/compiler/parser/ParserCallTests.java
@@ -2,6 +2,7 @@ package org.shedlang.compiler.parser;
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.shedlang.compiler.ast.UntypedNodeMatchers.*;
import static org.shedlang.compiler.parser.ParserTesting.parseString;
import static org.zwobble.precisely.AssertThat.assertThat;
@@ -121,6 +122,37 @@ public class ParserCallTests {
}
@Test
+ public void canParseNamedArgumentAfterPositionalArgument() {
+ var source = "f(a, .named = b)";
+
+ var node = parseString(source, Parser::parseTopLevelExpression);
+
+ assertThat(
+ node,
+ isUntypedCallNode()
+ .withArgs(
+ isUntypedArgsNode()
+ .withPositional(isSequence(
+ isUntypedReferenceNode("a")
+ ))
+ .withNamed(isSequence(
+ isUntypedNamedArgNode("named", isUntypedReferenceNode("b"))
+ ))
+ )
+ );
+ }
+
+ @Test
+ public void cannotParsePositionalArgumentAfterNamedArgument() {
+ var source = "f(.y = false, true)";
+
+ assertThrows(
+ PositionalArgAfterNamedArgError.class,
+ () -> parseString(source, Parser::parseTopLevelExpression)
+ );
+ }
+
+ @Test
public void argumentListCanHaveTrailingComma() {
var source = "f(a,)";