diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-12-02 21:24:23 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-12-02 21:26:19 +0000 |
| commit | 41fcbdb71e6603919f0b751998452a45b8d9a0a3 (patch) | |
| tree | 81bc8abd48f21655780f58cd395b2eb783322540 /src/test/java | |
| parent | 496e7f4addb7866fb1e419a98c52a870393296f4 (diff) | |
Support effects in effect handler methods
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineFunctionTests.java | 21 | ||||
| -rw-r--r-- | src/test/java/org/shedlang/compiler/patio/PatioCodeGenResumeTests.java | 3 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineFunctionTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineFunctionTests.java index bb8fb3ab..3fd914be 100644 --- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineFunctionTests.java +++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenDefineFunctionTests.java @@ -149,4 +149,25 @@ public class PatioCodeGenDefineFunctionTests { snapshotter.assertSnapshot(serialize(result)); } + + @Test + public void effectHandlerMethodSwapsEffectHandlerInBody(Snapshotter snapshotter) throws IOException { + var instruction = new ShidDefineFunction( + "f", + List.of(), + List.of(), + FreeVariables.empty(), + List.of( + Shid.pushUnit(), + Shid.resume() + ), + ShidDefineFunction.Variant.EFFECT_HANDLER_METHOD, + Sources.NULL + ); + var context = PatioCodeGenContext.EMPTY; + + var result = PatioCodeGen.generateInstruction(instruction, context); + + snapshotter.assertSnapshot(serialize(result)); + } } diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenResumeTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenResumeTests.java index 57d16015..b0a97f31 100644 --- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenResumeTests.java +++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenResumeTests.java @@ -18,7 +18,8 @@ public class PatioCodeGenResumeTests { var shid = Shid.resume(); var context = PatioCodeGenContext.EMPTY .temporaryPush(new PatioLocalRef("a")) - .temporaryPush(new PatioLocalRef("b")); + .temporaryPush(new PatioLocalRef("b")) + .stashEffectHandler(new PatioLocalRef("effect_handler")); var result = PatioCodeGen.generateInstruction(shid, context); |
