Debian Codegraph @

js/src/tests/test262/language/expressions/dynamic-import/namespace/await-ns-delete-exported-init-strict-strict.js

raw
1 // |reftest| async
2 'use strict';
3 // This file was procedurally generated from the following sources:
4 // - src/dynamic-import/ns-delete-exported-init-strict.case
5 // - src/dynamic-import/namespace/await.template
6 /*---
7 description: The [[Delete]] behavior for a key that describes an initialized exported binding on strict mode (value from await resolving)
8 esid: sec-finishdynamicimport
9 features: [dynamic-import]
10 flags: [generated, onlyStrict, async]
11 info: |
12 Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion )
13
14 1. If completion is an abrupt completion, ...
15 2. Otherwise,
16 ...
17 d. Let namespace be GetModuleNamespace(moduleRecord).
18 e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »).
19 f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »).
20
21 Runtime Semantics: GetModuleNamespace ( module )
22
23 ...
24 3. Let namespace be module.[[Namespace]].
25 4. If namespace is undefined, then
26 a. Let exportedNames be ? module.GetExportedNames(« »).
27 b. Let unambiguousNames be a new empty List.
28 c. For each name that is an element of exportedNames, do
29 i. Let resolution be ? module.ResolveExport(name, « »).
30 ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames.
31 d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames).
32 5. Return namespace.
33
34 ModuleNamespaceCreate ( module, exports )
35
36 ...
37 4. Let M be a newly created object.
38 5. Set M's essential internal methods to the definitions specified in 9.4.6.
39 7. Let sortedExports be a new List containing the same values as the list exports where the
40 values are ordered as if an Array of the same values had been sorted using Array.prototype.sort
41 using undefined as comparefn.
42 8. Set M.[[Exports]] to sortedExports.
43 9. Create own properties of M corresponding to the definitions in 26.3.
44 10. Set module.[[Namespace]] to M.
45 11. Return M.
46
47 26.3 Module Namespace Objects
48
49 A Module Namespace Object is a module namespace exotic object that provides runtime
50 property-based access to a module's exported bindings. There is no constructor function for
51 Module Namespace Objects. Instead, such an object is created for each module that is imported
52 by an ImportDeclaration that includes a NameSpaceImport.
53
54 In addition to the properties specified in 9.4.6 each Module Namespace Object has the
55 following own property:
56
57 26.3.1 @@toStringTag
58
59 The initial value of the @@toStringTag property is the String value "Module".
60
61 This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
62
63 Module Namespace Exotic Objects
64
65 A module namespace object is an exotic object that exposes the bindings exported from an
66 ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed
67 own properties of a module namespace exotic object and the binding names exported by the
68 Module. The exported bindings include any bindings that are indirectly exported using export *
69 export items. Each String-valued own property key is the StringValue of the corresponding
70 exported binding name. These are the only String-keyed properties of a module namespace exotic
71 object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true,
72 [[Configurable]]: false }. Module namespace objects are not extensible.
73
74
75 [...]
76 2. If Type(P) is Symbol, then
77 a. Return ? OrdinaryDelete(O, P).
78 3. Let exports be O.[[Exports]].
79 4. If P is an element of exports, return false.
80 5. Return true.
81
82 ---*/
83
84 async function fn() {
85 const ns = await import('./module-code_FIXTURE.js');
86
87 assert.throws(TypeError, function() {
88 delete ns.default;
89 }, 'delete: default');
90 assert.sameValue(
91 Reflect.deleteProperty(ns, 'default'), false, 'Reflect.deleteProperty: default'
92 );
93 assert.sameValue(ns.default, 42, 'binding unmodified: default');
94
95 assert.throws(TypeError, function() {
96 delete ns.local1;
97 }, 'delete: local1');
98 assert.sameValue(
99 Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1'
100 );
101 assert.sameValue(ns.local1, 'Test262', 'binding unmodified: local1');
102
103 assert.throws(TypeError, function() {
104 delete ns.renamed;
105 }, 'delete: renamed');
106 assert.sameValue(
107 Reflect.deleteProperty(ns, 'renamed'), false, 'Reflect.deleteProperty: renamed'
108 );
109 assert.sameValue(ns.renamed, 'TC39', 'binding unmodified: renamed');
110
111 assert.throws(TypeError, function() {
112 delete ns.indirect;
113 }, 'delete: indirect');
114 assert.sameValue(
115 Reflect.deleteProperty(ns, 'indirect'),
116 false,
117 'Reflect.deleteProperty: indirect'
118 );
119 assert.sameValue(ns.indirect, 'Test262', 'binding unmodified: indirect');
120 }
121
122 fn().then($DONE, $DONE).catch($DONE);