package org.shedlang.compiler.shid; import org.junit.jupiter.api.Test; import org.shedlang.compiler.ast.typed.Typed; import org.shedlang.compiler.types.Effects; import org.shedlang.compiler.types.NamespaceName; import org.shedlang.compiler.types.UserDefinedEffect; import static org.shedlang.compiler.shid.instructions.ShidMatchers.*; import static org.zwobble.precisely.AssertThat.assertThat; import static org.zwobble.precisely.Matchers.isSequence; public class ShidCodeGenBreakTests { private static final NamespaceName NAMESPACE_NAME = NamespaceName.of("Example"); private static final UserDefinedEffect EFFECT = Effects.userDefined(NAMESPACE_NAME, "Effect"); @Test public void expressionIsEvaluatedAndReturned() { var node = Typed.break_(EFFECT, Typed.stringLiteral("hello")); var context = ShidCodeGen.Context.EMPTY; var result = ShidCodeGen.compileFunctionStatement(node, context); assertThat(result.instructions(), isSequence( isShidPushString("hello"), isShidEffectHandlerBreak(EFFECT) )); } }