summaryrefslogtreecommitdiffstats
path: root/tests/run-make/wasm-symbols-different-module/verify-imports.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run-make/wasm-symbols-different-module/verify-imports.js')
-rw-r--r--tests/run-make/wasm-symbols-different-module/verify-imports.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/run-make/wasm-symbols-different-module/verify-imports.js b/tests/run-make/wasm-symbols-different-module/verify-imports.js
new file mode 100644
index 000000000..7e9f90cf8
--- /dev/null
+++ b/tests/run-make/wasm-symbols-different-module/verify-imports.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.imports(m);
+console.log('imports', list);
+if (list.length !== process.argv.length - 3)
+ throw new Error("wrong number of imports")
+
+const imports = new Map();
+for (let i = 3; i < process.argv.length; i++) {
+ const [module, name] = process.argv[i].split('/');
+ if (!imports.has(module))
+ imports.set(module, new Map());
+ imports.get(module).set(name, true);
+}
+
+for (let i of list) {
+ if (imports.get(i.module) === undefined || imports.get(i.module).get(i.name) === undefined)
+ throw new Error(`didn't find import of ${i.module}::${i.name}`);
+ imports.get(i.module).delete(i.name);
+
+ if (imports.get(i.module).size === 0)
+ imports.delete(i.module);
+}
+
+console.log(imports);
+if (imports.size !== 0) {
+ throw new Error('extra imports');
+}