From 1a43e1686bd55f5607459a80ff3cc8e34bbfde70 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 24 Jun 2023 21:12:17 +0100 Subject: Fix func index in local names section --- .../structure/WasmBinaryFormatModuleTests.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/test/java') 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 5941c790..5495d798 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 @@ -91,6 +91,28 @@ public class WasmBinaryFormatModuleTests { snapshotter.assertSnapshot(result); } + @Test + public void localNamesHaveCorrectFuncIndexWhenThereAreImportedFunctions(Snapshotter snapshotter) throws IOException, InterruptedException { + var module = WasmModule.EMPTY + .addFunction(new WasmFunction( + List.of( + new WasmLocal("paramA", WasmValueType.F32) + ), + List.of(), + List.of(WasmValueType.I32), + List.of(new WasmI32Const(0)) + )) + .addImport(new WasmImport( + "ModuleName1", + "EntityName1", + new WasmImportDescriptor.Func("Identifier1", new WasmFuncType(List.of(), List.of())) + )); + + var result = serializeModule(module); + + snapshotter.assertSnapshot(result); + } + @Test public void canSerializeModuleWithTableImports(Snapshotter snapshotter) throws IOException, InterruptedException { var module = WasmModule.EMPTY -- cgit v1.2.3