From 90792bb81602e61436988ccdf7345a04d54c2164 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Wed, 8 Nov 2023 20:38:02 +0000 Subject: Clarify typing around handler methods --- .../shedlang/compiler/parser/ParserTryTests.java | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src/test/java/org/shedlang/compiler/parser') 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())) )) ); } -- cgit v1.2.3