diff options
| author | Michael Williamson <mike@zwobble.org> | 2025-02-09 17:12:36 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2025-02-09 17:12:36 +0000 |
| commit | 09dcc2a2c64eb2544d810bbc586241346130d258 (patch) | |
| tree | ae1bd5a3da237b5bf8cf648c1abdd289ed6e87d1 /src/test/java/org/shedlang/compiler/parser | |
| parent | 8cab12eaca01f9778530f066cbc77d1c72adbd19 (diff) | |
Parse type-level params for function type
Diffstat (limited to 'src/test/java/org/shedlang/compiler/parser')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/parser/ParserFunctionTypeTests.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/parser/ParserFunctionTypeTests.java b/src/test/java/org/shedlang/compiler/parser/ParserFunctionTypeTests.java index 209220ad..319b0252 100644 --- a/src/test/java/org/shedlang/compiler/parser/ParserFunctionTypeTests.java +++ b/src/test/java/org/shedlang/compiler/parser/ParserFunctionTypeTests.java @@ -164,4 +164,36 @@ public class ParserFunctionTypeTests { .withEffect(isOptionalOf(isUntypedTypeLevelReferenceNode("Io"))) ); } + + @Test + public void canParseSingleTypeLevelParam() { + var source = "fn [A]() -> Unit"; + + var node = parseString(source, Parser::parseTopLevelTypeLevelExpression); + + assertThat( + node, + isUntypedFunctionTypeNode() + .withTypeLevelParams(isOptionalOf(isSequence( + isUntypedTypeParamNode("A") + ))) + ); + } + + @Test + public void canParseManyTypeLevelParams() { + var source = "fn [A, B, C]() -> Unit"; + + var node = parseString(source, Parser::parseTopLevelTypeLevelExpression); + + assertThat( + node, + isUntypedFunctionTypeNode() + .withTypeLevelParams(isOptionalOf(isSequence( + isUntypedTypeParamNode("A"), + isUntypedTypeParamNode("B"), + isUntypedTypeParamNode("C") + ))) + ); + } } |
