aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-06-25 16:51:53 +0100
committerMichael Williamson <mike@zwobble.org>2023-06-25 16:51:53 +0100
commitf1a64f8ac893d69e80c04b55f37f12ce36a7d71e (patch)
treefe13944461092b7931ec7e0d77d3eb7d1423dc64 /src/test/java
parent3d054b45c3cc440e84ed65f04b36dbcb26c6f402 (diff)
Add WASM code gen for local-load instruction
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenLocalLoadTests.java31
-rw-r--r--src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenLocalStoreTests.java2
2 files changed, 32 insertions, 1 deletions
diff --git a/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenLocalLoadTests.java b/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenLocalLoadTests.java
new file mode 100644
index 00000000..3a07ffd8
--- /dev/null
+++ b/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenLocalLoadTests.java
@@ -0,0 +1,31 @@
+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 WasmCodeGenLocalLoadTests {
+ @Test
+ public void localLoadCompilesToLocalGet(Snapshotter snapshotter) throws IOException, InterruptedException {
+ var instruction = Instructions.localLoad("x");
+ var context = WasmCodeGenContext.EMPTY
+ .addShedLocal("y")
+ .context()
+ .addShedLocal("x")
+ .context()
+ .addShedLocal("z")
+ .context();
+
+ var result = WasmCodeGen.generateInstruction(instruction, context);
+
+ var module = result.toFunction().toModule();
+ snapshotter.assertSnapshot(objdump(module));
+ }
+}
diff --git a/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenLocalStoreTests.java b/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenLocalStoreTests.java
index fe098819..ea82a5cb 100644
--- a/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenLocalStoreTests.java
+++ b/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenLocalStoreTests.java
@@ -13,7 +13,7 @@ import static org.shedlang.compiler.backends.wasm.structure.WasmObjdump.objdump;
@ExtendWith({SnapshotResolver.class})
public class WasmCodeGenLocalStoreTests {
@Test
- public void localStoreCompilesToLocalStore(Snapshotter snapshotter) throws IOException, InterruptedException {
+ public void localStoreCompilesToLocalSet(Snapshotter snapshotter) throws IOException, InterruptedException {
var instruction = Instructions.localStore("x");
var context = WasmCodeGenContext.EMPTY;