From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/run-make/wasm-export-all-symbols/verify.js | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/run-make/wasm-export-all-symbols/verify.js (limited to 'tests/run-make/wasm-export-all-symbols/verify.js') diff --git a/tests/run-make/wasm-export-all-symbols/verify.js b/tests/run-make/wasm-export-all-symbols/verify.js new file mode 100644 index 000000000..72db3356f --- /dev/null +++ b/tests/run-make/wasm-export-all-symbols/verify.js @@ -0,0 +1,32 @@ +const fs = require('fs'); +const process = require('process'); +const assert = require('assert'); +const buffer = fs.readFileSync(process.argv[2]); + +let m = new WebAssembly.Module(buffer); +let list = WebAssembly.Module.exports(m); +console.log('exports', list); + +const my_exports = {}; +let nexports = 0; + +for (const entry of list) { + if (entry.kind == 'function'){ + nexports += 1; + } + my_exports[entry.name] = entry.kind; +} + +if (my_exports.foo != "function") + throw new Error("`foo` wasn't defined"); + +if (my_exports.FOO != "global") + throw new Error("`FOO` wasn't defined"); + +if (my_exports.main === undefined) { + if (nexports != 1) + throw new Error("should only have one function export"); +} else { + if (nexports != 2) + throw new Error("should only have two function exports"); +} -- cgit v1.2.3