Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b282c85

Browse filesBrowse files
kballtargos
authored andcommitted
vm: increase code coverage of source_text_module.js
PR-URL: #28350 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 2142b6d commit b282c85
Copy full SHA for b282c85

File tree

Expand file treeCollapse file tree

1 file changed

+35
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+35
-0
lines changed
Open diff view settings
Collapse file
+35Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
'use strict';
2+
3+
// Flags: --experimental-vm-modules --expose-internals
4+
//
5+
const common = require('../common');
6+
7+
const assert = require('assert');
8+
9+
const { types } = require('util');
10+
const { SourceTextModule, wrapMap } = require('internal/vm/source_text_module');
11+
12+
const { importModuleDynamicallyCallback } =
13+
require('internal/process/esm_loader');
14+
15+
async function getNamespace() {
16+
const m = new SourceTextModule('');
17+
await m.link(() => 0);
18+
m.instantiate();
19+
await m.evaluate();
20+
return m.namespace;
21+
}
22+
23+
(async () => {
24+
const namespace = await getNamespace();
25+
const m = new SourceTextModule('export const A = "A";', {
26+
importModuleDynamically: common.mustCall((specifier, wrap) => {
27+
return namespace;
28+
})
29+
});
30+
await m.link(() => 0);
31+
m.instantiate();
32+
await m.evaluate();
33+
const ns = await importModuleDynamicallyCallback(wrapMap.get(m));
34+
assert.ok(types.isModuleNamespaceObject(ns));
35+
})().then(common.mustCall());

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.