package org.shedlang.compiler.shid; import org.junit.jupiter.api.Test; import org.shedlang.compiler.ast.typed.Typed; import org.shedlang.compiler.shid.instructions.ShidDefineEffect; import org.shedlang.compiler.types.Effects; import org.shedlang.compiler.types.NamespaceName; import static org.shedlang.compiler.shid.instructions.ShidMatchers.isShidLocalStore; import static org.zwobble.precisely.AssertThat.assertThat; import static org.zwobble.precisely.Matchers.*; public class ShidCodeGenEffectDefinitionTests { @Test public void effectDefinitionIsCompiledToDefineEffectInstruction() { var effect = Effects.userDefined(NamespaceName.of("Example", "Project"), "State"); var node = Typed.effectDefinition(effect); var context = ShidCodeGen.Context.EMPTY .addShedVal("State"); var result = ShidCodeGen.compileNamespaceStatement(node, context); assertThat(result.instructions(), isSequence( instanceOf( ShidDefineEffect.class, has("effect", x -> x.effect(), equalTo(effect)) ), isShidLocalStore("State__0") )); } }