From 8decaba8f75d16550d5f0e6caf9ddaff18dad38a Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 3 Dec 2023 18:13:30 +0000 Subject: Support exception handler method break --- .../patio/PatioCodeGenEffectHandlerBreakTests.java | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/test/java/org/shedlang/compiler/patio/PatioCodeGenEffectHandlerBreakTests.java (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenEffectHandlerBreakTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenEffectHandlerBreakTests.java new file mode 100644 index 00000000..128f001a --- /dev/null +++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenEffectHandlerBreakTests.java @@ -0,0 +1,31 @@ +package org.shedlang.compiler.patio; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.shedlang.compiler.patio.ast.operands.PatioLocalRef; +import org.shedlang.compiler.shid.instructions.Shid; +import org.shedlang.compiler.testing.snapshots.SnapshotResolver; +import org.shedlang.compiler.testing.snapshots.Snapshotter; +import org.shedlang.compiler.types.Effects; +import org.shedlang.compiler.types.NamespaceName; + +import java.io.IOException; + +import static org.shedlang.compiler.patio.PatioTesting.serialize; + +@ExtendWith({SnapshotResolver.class}) +public class PatioCodeGenEffectHandlerBreakTests { + @Test + public void effectHandlerBreakThrowsException(Snapshotter snapshotter) throws IOException { + var namespaceName = NamespaceName.of("Example", "Project"); + var effect = Effects.userDefined(namespaceName, "Effect"); + var shid = Shid.effectHandlerBreak(effect); + var context = PatioCodeGenContext.EMPTY + .temporaryPush(new PatioLocalRef("a")) + .temporaryPush(new PatioLocalRef("b")); + + var result = PatioCodeGen.generateInstruction(shid, context); + + snapshotter.assertSnapshot(serialize(result)); + } +} -- cgit v1.2.3