From 2fe51eb35031a9dd0c0b740fd893b9704614464e Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 23 Jul 2023 21:54:45 +0100 Subject: Support int-sub in Patio code gen --- .../compiler/patio/PatioCodeGenIntSubTests.java | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntSubTests.java (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntSubTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntSubTests.java new file mode 100644 index 00000000..9c0ccae9 --- /dev/null +++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntSubTests.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.operands.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 PatioCodeGenIntSubTests { + @Test + public void canGenerateCodeForIntSub(Snapshotter snapshotter) throws IOException { + var stackIr = Instructions.intSub(); + 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)); + } +} -- cgit v1.2.3