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/WasmBinaryFormatModuleTests.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/backends/wasm/structure/WasmBinaryFormatModuleTests.java b/src/test/java/org/shedlang/compiler/backends/wasm/structure/WasmBinaryFormatModuleTests.java
index 7cf142a4..4c26a55c 100644
--- a/src/test/java/org/shedlang/compiler/backends/wasm/structure/WasmBinaryFormatModuleTests.java
+++ b/src/test/java/org/shedlang/compiler/backends/wasm/structure/WasmBinaryFormatModuleTests.java
@@ -212,6 +212,44 @@ public class WasmBinaryFormatModuleTests {
snapshotter.assertSnapshot(result);
}
+ @Test
+ public void canSerializeModuleWithElementSegments(Snapshotter snapshotter) throws IOException, InterruptedException {
+ var module = WasmModule.EMPTY
+ .addFunction(new WasmFunction(
+ "f1",
+ List.of(),
+ List.of(),
+ List.of(),
+ new WasmExpression(List.of())
+ ))
+ .addFunction(new WasmFunction(
+ "f2",
+ List.of(),
+ List.of(),
+ List.of(),
+ new WasmExpression(List.of())
+ ))
+ .addFunction(new WasmFunction(
+ "f3",
+ List.of(),
+ List.of(),
+ List.of(),
+ new WasmExpression(List.of())
+ ))
+ .addTable(new WasmTable(new WasmTableType(
+ WasmReferenceType.FUNC_REF,
+ WasmLimits.min(1)
+ )))
+ .addElementSegment(WasmElementSegment.funcIndicesActive(List.of(
+ new WasmFuncIndex(0),
+ new WasmFuncIndex(2)
+ )));
+
+ var result = serializeModule(module);
+
+ snapshotter.assertSnapshot(result);
+ }
+
private String serializeModule(WasmModule module) throws IOException, InterruptedException {
Files.createDirectories(Path.of("tests-tmp"));
var temporaryDirectory = Files.createTempDirectory(Path.of("tests-tmp"), "WasmBinaryFormat");