From 3c4abe6920253f63621a314890878b6037335a73 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 25 Jun 2023 15:47:47 +0100 Subject: Add WASM code gen for push-unit instruction --- .../backends/wasm/WasmCodeGenPushUnitTests.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenPushUnitTests.java (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenPushUnitTests.java b/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenPushUnitTests.java new file mode 100644 index 00000000..919f57f8 --- /dev/null +++ b/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenPushUnitTests.java @@ -0,0 +1,27 @@ +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 WasmCodeGenPushUnitTests { + // TODO: handle larger ints + + @Test + public void pushIntIsCompiledToOperandInStack(Snapshotter snapshotter) throws IOException, InterruptedException { + var instruction = Instructions.pushUnit(); + var context = WasmCodeGenContext.EMPTY; + + var result = WasmCodeGen.generateInstruction(instruction, context); + + var module = result.toFunction().toModule(); + snapshotter.assertSnapshot(objdump(module)); + } +} -- cgit v1.2.3