aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/shedlang/compiler/backends/wasm/structure/binary/WasmBinaryFormatInstructionsTests.java57
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);
+ }
}