diff options
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushStringTests.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushStringTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushStringTests.java new file mode 100644 index 00000000..28989deb --- /dev/null +++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushStringTests.java @@ -0,0 +1,34 @@ +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 PatioCodeGenPushStringTests { + @Test + public void pushStringIsCompiledToDataAndIndexToData(Snapshotter snapshotter) throws IOException { + var stackIrInstruction = Instructions.pushString("hello"); + var context = PatioCodeGenContext.EMPTY; + + var result = PatioCodeGen.generateInstruction(stackIrInstruction, context); + + snapshotter.assertSnapshot(serialize(result)); + } + + @Test + public void canHaveMultipleStrings(Snapshotter snapshotter) throws IOException { + var context = PatioCodeGenContext.EMPTY; + + var result = PatioCodeGen.generateInstruction(Instructions.pushString("hello"), context); + result = PatioCodeGen.generateInstruction(Instructions.pushString("world"), result); + + snapshotter.assertSnapshot(serialize(result)); + } +} |
