diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-06-25 13:56:22 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-06-25 13:56:22 +0100 |
| commit | a4d0595b70aab0cc71a6f4721654a961190f5180 (patch) | |
| tree | a6625e91c6e4e6536e2239d0389f065bda1aea51 /src/test/java | |
| parent | 263db75901806c8a41721d38137f0cd7f03d35de (diff) | |
Support init funcs in WASM binary format
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/backends/wasm/structure/WasmBinaryFormatModuleTests.java | 33 |
1 files changed, 33 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 58c39b85..bab17edd 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 @@ -5,6 +5,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.shedlang.compiler.backends.wasm.structure.ast.instructions.WasmExpression; import org.shedlang.compiler.backends.wasm.structure.ast.instructions.WasmI32Const; import org.shedlang.compiler.backends.wasm.structure.ast.instructions.WasmI64Const; +import org.shedlang.compiler.backends.wasm.structure.ast.linking.WasmInitFunc; import org.shedlang.compiler.backends.wasm.structure.ast.modules.*; import org.shedlang.compiler.backends.wasm.structure.ast.types.*; import org.shedlang.compiler.testing.ProcessRunner; @@ -269,6 +270,38 @@ public class WasmBinaryFormatModuleTests { snapshotter.assertSnapshot(result); } + @Test + public void canSerializeModuleWithInitFuncs(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()) + )) + .addInitFunc(new WasmInitFunc(0, new WasmFuncIndex(2))) + .addInitFunc(new WasmInitFunc(4, new WasmFuncIndex(0))); + + 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"); |
