Debian Codegraph @

js/src/tests/test262/language/expressions/dynamic-import/catch/nested-block-import-catch-import-source-specifier-tostring.js

raw
1 // |reftest| skip async -- source-phase-imports is not supported
2 // This file was procedurally generated from the following sources:
3 // - src/dynamic-import/import-source-specifier-tostring.case
4 // - src/dynamic-import/catch/nested-block.template
5 /*---
6 description: ToString value of specifier (nested block)
7 esid: sec-import-call-runtime-semantics-evaluation
8 features: [source-phase-imports, dynamic-import]
9 flags: [generated, async]
10 info: |
11 ImportCall :
12 import( AssignmentExpression )
13
14 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule().
15 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null).
16 3. Let argRef be the result of evaluating AssignmentExpression.
17 4. Let specifier be ? GetValue(argRef).
18 5. Let promiseCapability be ! NewPromiseCapability(%Promise%).
19 6. Let specifierString be ToString(specifier).
20 7. IfAbruptRejectPromise(specifierString, promiseCapability).
21 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability).
22 9. Return promiseCapability.[[Promise]].
23
24
25 Import Calls
26
27 Runtime Semantics: Evaluation
28
29 ImportCall : import . source ( AssignmentExpression )
30 1. Return ? EvaluateImportCall(AssignmentExpression, source).
31
32 13.3.10.1.1 EvaluateImportCall ( specifierExpression, phase )
33 1. Let referrer be GetActiveScriptOrModule().
34 2. If referrer is null, set referrer to the current Realm Record.
35 3. Let specifierRef be ? Evaluation of specifierExpression.
36 4. Let specifier be ? GetValue(specifierRef).
37 5. Let promiseCapability be ! NewPromiseCapability(%Promise%).
38 6. Let specifierString be Completion(ToString(specifier)).
39 7. IfAbruptRejectPromise(specifierString, promiseCapability).
40 8. Let moduleRequest be a new ModuleRequest Record { [[Specifier]]: specifierString, [[Phase]]: phase }.
41 9. Perform HostLoadImportedModule(referrer, moduleRequest, empty, promiseCapability).
42 10. Return promiseCapability.[[Promise]].
43
44 16.2.1.7.2 GetModuleSource ( )
45 Source Text Module Record provides a GetModuleSource implementation that always returns an abrupt completion indicating that a source phase import is not available.
46 1. Throw a SyntaxError exception.
47
48 ---*/
49 // The following case is equivalent of the call of:
50 // import.source('./empty_FIXTURE.js')
51
52 const obj = {
53 toString() {
54 return './empty_FIXTURE.js';
55 }
56 };
57
58
59 {
60 import.source(obj).catch(error => {
61
62 assert.sameValue(error.name, 'SyntaxError');
63
64 }).then($DONE, $DONE);
65 };