({ stage, n })
| 12 | }); |
| 13 | |
| 14 | function main({ stage, n }) { |
| 15 | const arr = []; |
| 16 | let importSource = ''; |
| 17 | let useSource = 'export const result = 0 '; |
| 18 | for (let i = 0; i < n; i++) { |
| 19 | importSource += `import { value${i} } from 'mod${i}';\n`; |
| 20 | useSource += ` + value${i}\n`; |
| 21 | } |
| 22 | |
| 23 | if (stage === 'all') { |
| 24 | bench.start(); |
| 25 | } |
| 26 | for (let i = 0; i < n; i++) { |
| 27 | const m = new vm.SourceTextModule(` |
| 28 | export const value${i} = 1; |
| 29 | `); |
| 30 | arr.push(m); |
| 31 | } |
| 32 | |
| 33 | const root = new vm.SourceTextModule(` |
| 34 | ${importSource} |
| 35 | ${useSource}; |
| 36 | `); |
| 37 | |
| 38 | if (stage === 'link') { |
| 39 | bench.start(); |
| 40 | } |
| 41 | |
| 42 | root.linkRequests(arr); |
| 43 | for (let i = 0; i < n; i++) { |
| 44 | arr[i].linkRequests([]); |
| 45 | } |
| 46 | |
| 47 | if (stage === 'link') { |
| 48 | bench.end(n); |
| 49 | } |
| 50 | |
| 51 | if (stage === 'instantiate') { |
| 52 | bench.start(); |
| 53 | } |
| 54 | root.instantiate(); |
| 55 | if (stage === 'instantiate') { |
| 56 | bench.end(n); |
| 57 | } |
| 58 | |
| 59 | if (stage === 'evaluate') { |
| 60 | bench.start(); |
| 61 | } |
| 62 | root.evaluate(); |
| 63 | if (stage === 'evaluate' || stage === 'all') { |
| 64 | bench.end(n); |
| 65 | } |
| 66 | |
| 67 | assert.strictEqual(root.namespace.result, n); |
| 68 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…