]> git.lizzy.rs Git - rust.git/blob - tests/run-make/wasm-custom-section/foo.js
Rollup merge of #106715 - BoxyUwU:new_solver_triagebot, r=lcnr
[rust.git] / tests / run-make / wasm-custom-section / foo.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 sections = WebAssembly.Module.customSections(m, "baz");
8 console.log('section baz', sections);
9 assert.strictEqual(sections.length, 1);
10 let section = new Uint8Array(sections[0]);
11 console.log('contents', section);
12 assert.strictEqual(section.length, 2);
13 assert.strictEqual(section[0], 7);
14 assert.strictEqual(section[1], 8);
15
16 sections = WebAssembly.Module.customSections(m, "bar");
17 console.log('section bar', sections);
18 assert.strictEqual(sections.length, 1, "didn't pick up `bar` section from dependency");
19 section = new Uint8Array(sections[0]);
20 console.log('contents', section);
21 assert.strictEqual(section.length, 2);
22 assert.strictEqual(section[0], 3);
23 assert.strictEqual(section[1], 4);
24
25 sections = WebAssembly.Module.customSections(m, "foo");
26 console.log('section foo', sections);
27 assert.strictEqual(sections.length, 1, "didn't create `foo` section");
28 section = new Uint8Array(sections[0]);
29 console.log('contents', section);
30 assert.strictEqual(section.length, 4, "didn't concatenate `foo` sections");
31 assert.strictEqual(section[0], 5);
32 assert.strictEqual(section[1], 6);
33 assert.strictEqual(section[2], 1);
34 assert.strictEqual(section[3], 2);
35
36 process.exit(0);