From 90afeef2a50e017be593267c8420df410b2cef7f Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 26 Jun 2023 21:16:03 +0100 Subject: Add WASM code gen for call instruction with no args --- .../backends/wasm/WasmCodeGenCallTests.java | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenCallTests.java (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenCallTests.java b/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenCallTests.java new file mode 100644 index 00000000..35255ed8 --- /dev/null +++ b/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenCallTests.java @@ -0,0 +1,26 @@ +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 java.util.List; + +import static org.shedlang.compiler.backends.wasm.structure.WasmObjdump.objdump; + +@ExtendWith({SnapshotResolver.class}) +public class WasmCodeGenCallTests { + @Test + public void canCallFunctionWithNoArgs(Snapshotter snapshotter) throws IOException, InterruptedException { + var instruction = Instructions.call(0, List.of()); + var context = WasmCodeGenContext.EMPTY; + + var result = WasmCodeGen.generateInstruction(instruction, context); + + var module = result.toFunction().toModule(); + snapshotter.assertSnapshot(objdump(module)); + } +} -- cgit v1.2.3