diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-11-08 20:38:02 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-11-08 20:38:02 +0000 |
| commit | 90792bb81602e61436988ccdf7345a04d54c2164 (patch) | |
| tree | 7b96ced719e365432f4d9fafe72d6a67a2b5b5b0 /src/test/java/org/shedlang/compiler/parser | |
| parent | 704531beb6a43e4f515e2a4dd30c65c08bba5aea (diff) | |
Clarify typing around handler methods
Diffstat (limited to 'src/test/java/org/shedlang/compiler/parser')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/parser/ParserTryTests.java | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/test/java/org/shedlang/compiler/parser/ParserTryTests.java b/src/test/java/org/shedlang/compiler/parser/ParserTryTests.java index 0782cdd4..3a1a2ac2 100644 --- a/src/test/java/org/shedlang/compiler/parser/ParserTryTests.java +++ b/src/test/java/org/shedlang/compiler/parser/ParserTryTests.java @@ -5,7 +5,7 @@ import org.junit.jupiter.api.Test; import static org.shedlang.compiler.ast.untyped.UntypedNodeMatchers.*; import static org.shedlang.compiler.parser.ParserTesting.parseString; import static org.zwobble.precisely.AssertThat.assertThat; -import static org.zwobble.precisely.Matchers.isSequence; +import static org.zwobble.precisely.Matchers.*; public class ParserTryTests { @Test @@ -15,9 +15,10 @@ public class ParserTryTests { 1; } handle State { fun read() { + resume 42; } - fun write() { + fun write(value) { } } """; @@ -32,10 +33,21 @@ public class ParserTryTests { ))) .withHandledEffect(isUntypedTypeLevelReferenceNode("State")) .withHandlerMethods(isSequence( - isUntypedFunctionDefinitionNode() - .withName("read"), - isUntypedFunctionDefinitionNode() + isUntypedTryHandlerMethodNode() + .withName("read") + .withParams(isUntypedParamsNode(isSequence(), isSequence())) + .withBody(isUntypedBlockNode(isSequence( + isUntypedResumeNode(isOptionalOf(isUntypedIntLiteralNode(42))) + ))), + isUntypedTryHandlerMethodNode() .withName("write") + .withParams(isUntypedParamsNode( + isSequence( + isUntypedParamNode("value", isOptionalEmpty()) + ), + isSequence() + )) + .withBody(isUntypedBlockNode(isSequence())) )) ); } |
