aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-07-22 11:07:53 +0100
committerMichael Williamson <mike@zwobble.org>2023-07-22 11:08:22 +0100
commitfec2b177288643b258fa65bb4b660f080a53e960 (patch)
treea8378baacaf1d0dcb38d94effc4a08bf9c2cdb3b /src/test/java
parentf525339cdcab1a44d370ffe619d46bdc2116c3b5 (diff)
Add Patio code gen for push-string
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenPushStringTests.java34
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));
+ }
+}