diff options
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenPushStringTests.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenPushStringTests.java b/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenPushStringTests.java new file mode 100644 index 00000000..79dd78d1 --- /dev/null +++ b/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenPushStringTests.java @@ -0,0 +1,36 @@ +package org.shedlang.compiler.backends.wasm; + +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.backends.wasm.structure.WasmObjdump.objdump; + +@ExtendWith({SnapshotResolver.class}) +public class WasmCodeGenPushStringTests { + @Test + public void pushStringIsCompiledToDataAndIndexToData(Snapshotter snapshotter) throws IOException, InterruptedException { + var instruction = Instructions.pushString("hello"); + var context = WasmCodeGenContext.EMPTY; + + var result = WasmCodeGen.generateInstruction(instruction, context); + + var module = result.toFunction().toModule(); + snapshotter.assertSnapshot(objdump(module)); + } + + @Test + public void canHaveMultipleStrings(Snapshotter snapshotter) throws IOException, InterruptedException { + var context = WasmCodeGenContext.EMPTY; + + var result = WasmCodeGen.generateInstruction(Instructions.pushString("hello"), context); + result = WasmCodeGen.generateInstruction(Instructions.pushString("world"), result); + + var module = result.toFunction().toModule(); + snapshotter.assertSnapshot(objdump(module)); + } +} |
