diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-12-26 22:36:08 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-12-26 22:36:08 +0000 |
| commit | f1c08d241b831023ce9bd71806e4352350b54f74 (patch) | |
| tree | e66150e6fd26950e749b9cf7c95a3fa602e80aa9 /src/test/java | |
| parent | adadf82937836a7e0a80c51e34b049021a1ce60f (diff) | |
Extract serializeInstructions()
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/backends/wasm/structure/binary/WasmBinaryFormatInstructionsTests.java | 57 |
1 files changed, 29 insertions, 28 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 c7c39691..797c8275 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 @@ -20,42 +20,28 @@ public class WasmBinaryFormatInstructionsTests { @Test public void canSerializeI32Add(Snapshotter snapshotter) throws IOException, InterruptedException { - var module = WasmModule.EMPTY - .addFunction(new WasmFunction( - "f", - List.of(), - List.of(), - List.of(), - new WasmExpression(List.of( - new WasmI32Const(0), - new WasmI32Const(0), - new WasmI32Add(), - new WasmDrop() - )) - )); + var instructions = List.of( + new WasmI32Const(0), + new WasmI32Const(0), + new WasmI32Add(), + new WasmDrop() + ); - var result = serializeModuleWasm32(module); + var result = serializeInstructions(instructions); snapshotter.assertSnapshot(result); } @Test public void canSerializeI64Add(Snapshotter snapshotter) throws IOException, InterruptedException { - var module = WasmModule.EMPTY - .addFunction(new WasmFunction( - "f", - List.of(), - List.of(), - List.of(), - new WasmExpression(List.of( - new WasmI64Const(0), - new WasmI64Const(0), - new WasmI64Add(), - new WasmDrop() - )) - )); + var instructions = List.of( + new WasmI64Const(0), + new WasmI64Const(0), + new WasmI64Add(), + new WasmDrop() + ); - var result = serializeModuleWasm32(module); + var result = serializeInstructions(instructions); snapshotter.assertSnapshot(result); } @@ -162,4 +148,19 @@ public class WasmBinaryFormatInstructionsTests { snapshotter.assertSnapshot(result); } + + private String serializeInstructions(List + <? extends WasmInstruction> instructions + ) throws IOException, InterruptedException { + var module = WasmModule.EMPTY + .addFunction(new WasmFunction( + "f", + List.of(), + List.of(), + List.of(), + new WasmExpression(instructions) + )); + + return serializeModuleWasm32(module); + } } |
