diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-07-20 15:28:05 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-07-20 15:28:05 +0100 |
| commit | bd56a334bc2b9c9670c6d50e55939fb67389317c (patch) | |
| tree | 9ec17ca96fb0f531e507b68752bc324174f5e7cf /src/test/java | |
| parent | 2d6ca67c0a0ca4e72ab409e5503a112f30e1f0a7 (diff) | |
Add Patio code gen for int-add
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntAddTests.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntAddTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntAddTests.java new file mode 100644 index 00000000..11de42eb --- /dev/null +++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntAddTests.java @@ -0,0 +1,28 @@ +package org.shedlang.compiler.patio; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.shedlang.compiler.patio.ast.PatioLocalRef; +import org.shedlang.compiler.stackir.instructions.Instructions; +import org.shedlang.compiler.testing.snapshots.SnapshotResolver; +import org.shedlang.compiler.testing.snapshots.Snapshotter; + +import java.io.IOException; + +import static org.shedlang.compiler.patio.PatioTesting.serialize; + +@ExtendWith({SnapshotResolver.class}) +public class PatioCodeGenIntAddTests { + @Test + public void intAddGeneratesIntAddInstruction(Snapshotter snapshotter) throws IOException { + var stackIr = Instructions.intAdd(); + var context = PatioCodeGenContext.EMPTY + .temporaryPush(new PatioLocalRef("a")) + .temporaryPush(new PatioLocalRef("b")) + .temporaryPush(new PatioLocalRef("c")); + + var result = PatioCodeGen.generateInstruction(stackIr, context); + + snapshotter.assertSnapshot(serialize(result)); + } +} |
