diff options
| author | Michael Williamson <mike@zwobble.org> | 2024-12-22 20:31:03 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2024-12-22 20:31:03 +0000 |
| commit | c9b5c7bd986f15114df7dcfc405c4eca11cbf25f (patch) | |
| tree | 9026849d171307bc5d47a416ed913c200649ea0b /src/test/java/org/shedlang/compiler/backends | |
| parent | 4db39d53fa6524e43f57252fc60dcc6d831775ff (diff) | |
Support Wasm block types with multiple results
Diffstat (limited to 'src/test/java/org/shedlang/compiler/backends')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/backends/wasm/structure/binary/WasmBinaryFormatInstructionsTests.java | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/test/java/org/shedlang/compiler/backends/wasm/structure/binary/WasmBinaryFormatInstructionsTests.java b/src/test/java/org/shedlang/compiler/backends/wasm/structure/binary/WasmBinaryFormatInstructionsTests.java index a14763d5..b9f2d9c2 100644 --- a/src/test/java/org/shedlang/compiler/backends/wasm/structure/binary/WasmBinaryFormatInstructionsTests.java +++ b/src/test/java/org/shedlang/compiler/backends/wasm/structure/binary/WasmBinaryFormatInstructionsTests.java @@ -1,10 +1,10 @@ package org.shedlang.compiler.backends.wasm.structure.binary; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.shedlang.compiler.backends.wasm.structure.ast.instructions.*; import org.shedlang.compiler.backends.wasm.structure.ast.modules.*; +import org.shedlang.compiler.backends.wasm.structure.ast.types.WasmFuncType; import org.shedlang.compiler.backends.wasm.structure.ast.types.WasmLimits; import org.shedlang.compiler.backends.wasm.structure.ast.types.WasmMemoryType; import org.shedlang.compiler.backends.wasm.structure.ast.types.WasmValueType; @@ -55,12 +55,16 @@ public class WasmBinaryFormatInstructionsTests { } @Test - @Disabled("WIP") public void canSerializeBlockTypeMultipleValues(Snapshotter snapshotter) throws IOException, InterruptedException { + var funcType = new WasmFuncType( + List.of(), + List.of(WasmValueType.I64, WasmValueType.I32) + ); + var instructions = List.of( new WasmI32Const(0), new WasmIf( - WasmBlockType.of(WasmValueType.I64, WasmValueType.I32), + WasmBlockType.of(funcType), List.of( new WasmI64Const(0), new WasmI32Const(0) @@ -70,10 +74,21 @@ public class WasmBinaryFormatInstructionsTests { new WasmI32Const(1) ) ), + new WasmDrop(), new WasmDrop() ); - var result = serializeInstructions(instructions); + var module = WasmModule.EMPTY + .addType(funcType) + .addFunction(new WasmFunction( + "f", + List.of(), + List.of(), + List.of(), + new WasmExpression(instructions) + )); + + var result = serializeModuleWasm32(module); snapshotter.assertSnapshot(result); } @@ -326,7 +341,7 @@ public class WasmBinaryFormatInstructionsTests { List.of(), new WasmExpression(List.of( new WasmTry( - new WasmBlockType(List.of(WasmValueType.I32)), + WasmBlockType.of(WasmValueType.I32), List.of(), List.of( new WasmI32Const(42) @@ -361,7 +376,7 @@ public class WasmBinaryFormatInstructionsTests { List.of(), new WasmExpression(List.of( new WasmTry( - new WasmBlockType(List.of(WasmValueType.I32)), + WasmBlockType.of(WasmValueType.I32), List.of( new WasmCatchBlock( new WasmTagName("Error1"), |
