From 0b3efd133423fc4b6c6e497cc1decf77ab208ad0 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Wed, 19 Jul 2023 21:22:15 +0100 Subject: Add Patio code gen for push-bool --- .../compiler/patio/PatioCodeGenPushBoolTests.java | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushBoolTests.java (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushBoolTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushBoolTests.java new file mode 100644 index 00000000..75c471f3 --- /dev/null +++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushBoolTests.java @@ -0,0 +1,32 @@ +package org.shedlang.compiler.patio; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +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 PatioCodeGenPushBoolTests { + @Test + public void pushBoolFalseInstructionGeneratesPushIntZeroInstruction(Snapshotter snapshotter) throws IOException { + var stackIr = Instructions.pushBool(false); + + var result = PatioCodeGen.generateInstruction(stackIr); + + snapshotter.assertSnapshot(serialize(result)); + } + + @Test + public void pushBoolTrueInstructionGeneratesPushIntOneInstruction(Snapshotter snapshotter) throws IOException { + var stackIr = Instructions.pushBool(true); + + var result = PatioCodeGen.generateInstruction(stackIr); + + snapshotter.assertSnapshot(serialize(result)); + } +} -- cgit v1.2.3