aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioResumeTests.java
blob: e90670d15220f1ee4e2abe3eb3000dfd08cd3cda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package org.shedlang.compiler.shidtopatio;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.shedlang.compiler.patio.operands.PatioLocalRef;
import org.shedlang.compiler.shid.instructions.Shid;
import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
import org.shedlang.compiler.testing.snapshots.Snapshotter;

import java.io.IOException;

import static org.shedlang.compiler.shidtopatio.ShidToPatioTesting.serialize;

@ExtendWith({SnapshotResolver.class})
public class ShidToPatioResumeTests {
    @Test
    public void resumeInstructionGeneratesResumeInstruction(Snapshotter snapshotter) throws IOException {
        var shid = Shid.resume();
        var context = ShidToPatioContext.EMPTY
            .temporaryPush(new PatioLocalRef("a"))
            .temporaryPush(new PatioLocalRef("b"))
            .stashEffectHandler(new PatioLocalRef("effect_handler"))
            .stashGcRootStackIndex(new PatioLocalRef("gc_root_stack_index"));

        var result = ShidToPatio.generateInstruction(shid, context);

        snapshotter.assertSnapshot(serialize(result));
    }
}