]> git.proxmox.com Git - rustc.git/blob - src/test/run-make/wasm-export-all-symbols/verify.js
Update unsuspicious file list
[rustc.git] / src / test / run-make / wasm-export-all-symbols / verify.js
1 const fs = require('fs');
2 const process = require('process');
3 const assert = require('assert');
4 const buffer = fs.readFileSync(process.argv[2]);
5
6 let m = new WebAssembly.Module(buffer);
7 let list = WebAssembly.Module.exports(m);
8 console.log('exports', list);
9
10 const my_exports = {};
11 let nexports = 0;
12
13 for (const entry of list) {
14 if (entry.kind == 'function'){
15 nexports += 1;
16 }
17 my_exports[entry.name] = entry.kind;
18 }
19
20 if (my_exports.foo != "function")
21 throw new Error("`foo` wasn't defined");
22
23 if (my_exports.FOO != "global")
24 throw new Error("`FOO` wasn't defined");
25
26 if (my_exports.main === undefined) {
27 if (nexports != 1)
28 throw new Error("should only have one function export");
29 } else {
30 if (nexports != 2)
31 throw new Error("should only have two function exports");
32 }