Debian Codegraph @

js/src/tests/test262/language/expressions/dynamic-import/update-to-dynamic-import.js

raw
1 // |reftest| async
2 // Copyright (C) 2018 Leo Balter. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 description: >
6 Resolve imports after a binding update
7 esid: sec-finishdynamicimport
8 info: |
9 Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion )
10
11 2. Otherwise,
12 a. Assert: completion is a normal completion and completion.[[Value]] is undefined.
13 b. Let moduleRecord be ! HostResolveImportedModule(referencingScriptOrModule, specifier).
14 c. Assert: Evaluate has already been invoked on moduleRecord and successfully completed.
15 d. Let namespace be GetModuleNamespace(moduleRecord).
16 ...
17 f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »).
18 flags: [async]
19 features: [dynamic-import]
20 includes: [asyncHelpers.js]
21 ---*/
22
23 async function fn() {
24 const first = await import('./update-to-dynamic-import_FIXTURE.js');
25 assert.sameValue(first.x, 'first', 'the other module has not been evaluated yet');
26
27 const other = await first.default();
28
29 assert.sameValue(first.x, 'other', 'the other module is only evaluated after calling import()');
30 assert.sameValue(other.default, 42);
31 }
32
33 asyncTest(fn);