aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-06-25 15:59:22 +0100
committerMichael Williamson <mike@zwobble.org>2023-06-25 15:59:22 +0100
commitb8ef288f0d552272b2086deb03b1d56fb25c7275 (patch)
treecb9720a3c21a1fb79fb9d830a392c13540480fdf /src/test/java
parent6aa1d4c0dd57790b65f90b2c69b484ad64ce74bc (diff)
Add WASM code gen for discard instruction
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenDiscardTests.java25
-rw-r--r--src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenPushUnitTests.java2
2 files changed, 26 insertions, 1 deletions
diff --git a/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenDiscardTests.java b/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenDiscardTests.java
new file mode 100644
index 00000000..2b1d84d3
--- /dev/null
+++ b/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenDiscardTests.java
@@ -0,0 +1,25 @@
+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 WasmCodeGenDiscardTests {
+ @Test
+ public void discardCompilesToDrop(Snapshotter snapshotter) throws IOException, InterruptedException {
+ var instruction = Instructions.discard();
+ var context = WasmCodeGenContext.EMPTY;
+
+ 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/WasmCodeGenPushUnitTests.java b/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenPushUnitTests.java
index ed9f3221..a58eb091 100644
--- a/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenPushUnitTests.java
+++ b/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenPushUnitTests.java
@@ -13,7 +13,7 @@ import static org.shedlang.compiler.backends.wasm.structure.WasmObjdump.objdump;
@ExtendWith({SnapshotResolver.class})
public class WasmCodeGenPushUnitTests {
@Test
- public void pushIntIsCompiledToOperandInStack(Snapshotter snapshotter) throws IOException, InterruptedException {
+ public void pushUnitIsCompiledToOperandInStack(Snapshotter snapshotter) throws IOException, InterruptedException {
var instruction = Instructions.pushUnit();
var context = WasmCodeGenContext.EMPTY;