diff --git a/src/dynamic-import/catch/nested-with.template b/src/dynamic-import/catch/nested-with.template deleted file mode 100644 index e88b46e6741bae3a2ff4c51fe8e75c690524f974..0000000000000000000000000000000000000000 --- a/src/dynamic-import/catch/nested-with.template +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2018 Leo Balter. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -path: language/module-code/dynamic-import/catch/nested-with-import-catch- -name: nested with -esid: sec-import-call-runtime-semantics-evaluation -info: | - ImportCall : - import( AssignmentExpression ) - - 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). - 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). - 3. Let argRef be the result of evaluating AssignmentExpression. - 4. Let specifier be ? GetValue(argRef). - 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). - 6. Let specifierString be ToString(specifier). - 7. IfAbruptRejectPromise(specifierString, promiseCapability). - 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). - 9. Return promiseCapability.[[Promise]]. -features: [dynamic-import] -flags: [async, noStrict] ----*/ - -with ({}) { - /*{ import }*/.catch(error => { - - /*{ body }*/ - - }).then($DONE, $DONE); -} - \ No newline at end of file diff --git a/src/dynamic-import/default/nested-with.template b/src/dynamic-import/default/nested-with.template deleted file mode 100644 index 05203214971a8b7663828dbb08a6a3cfaecb48af..0000000000000000000000000000000000000000 --- a/src/dynamic-import/default/nested-with.template +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2018 Leo Balter. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -path: language/module-code/dynamic-import/usage/nested-with-import-then- -name: nested with -esid: sec-import-call-runtime-semantics-evaluation -info: | - ImportCall : - import( AssignmentExpression ) - - 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). - 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). - 3. Let argRef be the result of evaluating AssignmentExpression. - 4. Let specifier be ? GetValue(argRef). - 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). - 6. Let specifierString be ToString(specifier). - 7. IfAbruptRejectPromise(specifierString, promiseCapability). - 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). - 9. Return promiseCapability.[[Promise]]. -features: [dynamic-import] -flags: [async, noStrict] ----*/ - -with ({}) { - /*{ import }*/.then(imported => { - - /*{ body }*/ - - }).then($DONE, $DONE).catch($DONE); -} diff --git a/src/dynamic-import/eval-script-code-host-resolves-module-code.case b/src/dynamic-import/eval-script-code-host-resolves-module-code.case new file mode 100644 index 0000000000000000000000000000000000000000..4963710137c98fad4af27ed1c3cbdc7aaa5db7bb --- /dev/null +++ b/src/dynamic-import/eval-script-code-host-resolves-module-code.case @@ -0,0 +1,18 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: import() from a ascript code can load a file with module code +template: default +---*/ + +//- setup +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + +//- import +import('./module-code_FIXTURE.js') +//- body +assert.sameValue(imported.default, 42); +assert.sameValue(imported.x, 'Test262'); +assert.sameValue(imported.z, 42); diff --git a/src/dynamic-import/eval-script-code-target.case b/src/dynamic-import/eval-script-code-target.case new file mode 100644 index 0000000000000000000000000000000000000000..a73dfc91d96b99c5cfd0339ac1a9209c85dbec5a --- /dev/null +++ b/src/dynamic-import/eval-script-code-target.case @@ -0,0 +1,22 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + import() from a module code can load a file with script code, but the target + is resolved into a Module Record +info: | + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. +template: catch +flags: [module] +---*/ + +//- import +import('./script-code_FIXTURE.js') +//- body +assert.sameValue(error.name, 'SyntaxError'); diff --git a/src/dynamic-import/namespace/await.template b/src/dynamic-import/namespace/await.template new file mode 100644 index 0000000000000000000000000000000000000000..f2ad5afe0a7d630358578d64e277aa66e7012f6a --- /dev/null +++ b/src/dynamic-import/namespace/await.template @@ -0,0 +1,81 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/ns/await- +name: value from await resolving +esid: sec-finishdynamicimport +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +features: [dynamic-import] +flags: [async] +---*/ + +async function fn() { + const ns = await /*{ import }*/; + + /*{ body }*/ +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/src/dynamic-import/namespace/promise.template b/src/dynamic-import/namespace/promise.template new file mode 100644 index 0000000000000000000000000000000000000000..fce701c04ba3fd793d770e34049684d1dd6d33ab --- /dev/null +++ b/src/dynamic-import/namespace/promise.template @@ -0,0 +1,79 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/ns/promise-then- +name: value from promise then +esid: sec-finishdynamicimport +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +features: [dynamic-import] +flags: [async] +---*/ + +/*{ import }*/.then(ns => { + + /*{ body }*/ + +}).then($DONE, $DONE).catch($DONE); diff --git a/src/dynamic-import/ns-Symbol-toStringTag.case b/src/dynamic-import/ns-Symbol-toStringTag.case new file mode 100644 index 0000000000000000000000000000000000000000..9ac7e8b62e7cb3f714ff70a47edb95c6d09453d1 --- /dev/null +++ b/src/dynamic-import/ns-Symbol-toStringTag.case @@ -0,0 +1,29 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Module namespace objects have a Symbol.toStringTag +template: namespace +info: | + @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: false }. +features: [Symbol.toStringTag] +---*/ + +//- import +import('./module-code_FIXTURE.js') +//- body +assert.sameValue(ns[Symbol.toStringTag], 'Module'); + +// propertyHelper.js is not appropriate for this test because it assumes that +// the object exposes the ordinary object's implementation of [[Get]], [[Set]], +// [[Delete]], and [[OwnPropertyKeys]], which the module namespace exotic +// object does not. +var desc = Object.getOwnPropertyDescriptor(ns, Symbol.toStringTag); + +assert.sameValue(desc.enumerable, false, 'reports as non-enumerable'); +assert.sameValue(desc.writable, false, 'reports as non-writable'); +assert.sameValue(desc.configurable, false, 'reports as non-configurable'); diff --git a/src/dynamic-import/ns-define-own-property.case b/src/dynamic-import/ns-define-own-property.case new file mode 100644 index 0000000000000000000000000000000000000000..2e909bc67f0817545c8fed2bb5dd5de1a51a61ea --- /dev/null +++ b/src/dynamic-import/ns-define-own-property.case @@ -0,0 +1,114 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-defineownproperty-p-desc +desc: > + The [[DefineOwnProperty]] internal method returns `true` if no change is + requested, and `false` otherwise. +features: [Symbol.iterator, Reflect, Symbol, Symbol.toStringTag] +template: namespace +---*/ + +//- setup +var sym = Symbol('test262'); + +const exported = ['local1', 'renamed', 'indirect']; + +//- import +import('./define-own-property_FIXTURE.js') +//- body +// Non-existant properties. + +for (const key of ['local2', 0, sym, Symbol.iterator]) { + assert.sameValue( + Reflect.defineProperty(ns, key, {}), + false, + 'Reflect.defineProperty: ' + key.toString() + ); + assert.throws(TypeError, function() { + Object.defineProperty(ns, key, {}); + }, 'Object.defineProperty: ' + key.toString()); +} + +// Own properties. No change requested. + +for (const key of ([...exported, Symbol.toStringTag])) { + assert.sameValue( + Reflect.defineProperty(ns, key, {}), + true, + `No change requested, Reflect.defineProperty: ${key.toString()}` + ); + assert.sameValue( + Object.defineProperty(ns, key, {}), + ns, + `No change requested, Object.defineProperty: ${key.toString()}` + ); + +} + +assert.sameValue( + Reflect.defineProperty(ns, 'indirect', + {writable: true, enumerable: true, configurable: false}), + true, + 'Reflect.defineProperty: indirect' +); +assert.sameValue( + Object.defineProperty(ns, 'indirect', + {writable: true, enumerable: true, configurable: false}), + ns, + 'Object.defineProperty: indirect' +); + +assert.sameValue( + Reflect.defineProperty(ns, Symbol.toStringTag, + {value: "Module", writable: false, enumerable: false, + configurable: false}), + true, + 'Reflect.defineProperty: Symbol.toStringTag' +); +assert.sameValue( + Object.defineProperty(ns, Symbol.toStringTag, + {value: "Module", writable: false, enumerable: false, + configurable: false}), + ns, + 'Object.defineProperty: Symbol.toStringTag' +); + + +// Own properties. Change requested. + +for (const key of ([...exported, Symbol.toStringTag])) { + assert.sameValue( + Reflect.defineProperty(ns, key, {value: 123}), + false, + `Change requested, Reflect.defineProperty: ${key.toString()}` + ); + assert.throws(TypeError, function() { + Object.defineProperty(ns, key, {value: 123}); + }, `Change requested, Object.defineProperty: ${key.toString()}`); +} + +assert.sameValue( + Reflect.defineProperty(ns, 'indirect', + {writable: true, enumerable: true, configurable: true}), + false, + 'Reflect.defineProperty: indirect' +); +assert.throws(TypeError, function() { + Object.defineProperty(ns, 'indirect', + {writable: true, enumerable: true, configurable: true}); +}, 'Object.defineProperty: indirect'); + +assert.sameValue( + Reflect.defineProperty(ns, Symbol.toStringTag, + {value: "module", writable: false, enumerable: false, + configurable: false}), + false, + 'Reflect.defineProperty: Symbol.toStringTag' +); +assert.throws(TypeError, function() { + Object.defineProperty(ns, Symbol.toStringTag, + {value: "module", writable: false, enumerable: false, + configurable: false}); +}, 'Object.defineProperty: Symbol.toStringTag'); diff --git a/src/dynamic-import/ns-delete-exported-init-no-strict.case b/src/dynamic-import/ns-delete-exported-init-no-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..e0aaeac8453f70d0f3acd7dc19ece2cb9ec530d5 --- /dev/null +++ b/src/dynamic-import/ns-delete-exported-init-no-strict.case @@ -0,0 +1,47 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-delete-p +desc: > + The [[Delete]] behavior for a key that describes an initialized exported + binding on non strict mode +info: | + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryDelete(O, P). + 3. Let exports be O.[[Exports]]. + 4. If P is an element of exports, return false. + 5. Return true. +template: namespace +flags: [noStrict] +---*/ + +//- import +import('./module-code_FIXTURE.js') +//- body +assert.sameValue(delete ns.default, false, 'delete: default'); +assert.sameValue( + Reflect.deleteProperty(ns, 'default'), false, 'Reflect.deleteProperty: default' +); +assert.sameValue(ns.default, 42, 'binding unmodified: default'); + +assert.sameValue(delete ns.local1, false, 'delete: local1'); +assert.sameValue( + Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1' +); +assert.sameValue(ns.local1, 'Test262', 'binding unmodified: local1'); + +assert.sameValue(delete ns.renamed, false, 'delete: renamed'); +assert.sameValue( + Reflect.deleteProperty(ns, 'renamed'), false, 'Reflect.deleteProperty: renamed' +); +assert.sameValue(ns.renamed, 'TC39', 'binding unmodified: renamed'); + +assert.sameValue(delete ns.indirect, false, 'delete: indirect'); +assert.sameValue( + Reflect.deleteProperty(ns, 'indirect'), + false, + 'Reflect.deleteProperty: indirect' +); +assert.sameValue(ns.indirect, 'Test262', 'binding unmodified: indirect'); diff --git a/src/dynamic-import/ns-delete-exported-init-strict.case b/src/dynamic-import/ns-delete-exported-init-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..a4b4f0a9d433e7b2a0b87c6aca93a5560af7bb56 --- /dev/null +++ b/src/dynamic-import/ns-delete-exported-init-strict.case @@ -0,0 +1,55 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-delete-p +desc: > + The [[Delete]] behavior for a key that describes an initialized exported + binding on strict mode +info: | + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryDelete(O, P). + 3. Let exports be O.[[Exports]]. + 4. If P is an element of exports, return false. + 5. Return true. +template: namespace +flags: [onlyStrict] +---*/ + +//- import +import('./module-code_FIXTURE.js') +//- body +assert.throws(TypeError, function() { + delete ns.default; +}, 'delete: default'); +assert.sameValue( + Reflect.deleteProperty(ns, 'default'), false, 'Reflect.deleteProperty: default' +); +assert.sameValue(ns.default, 42, 'binding unmodified: default'); + +assert.throws(TypeError, function() { + delete ns.local1; +}, 'delete: local1'); +assert.sameValue( + Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1' +); +assert.sameValue(ns.local1, 'Test262', 'binding unmodified: local1'); + +assert.throws(TypeError, function() { + delete ns.renamed; +}, 'delete: renamed'); +assert.sameValue( + Reflect.deleteProperty(ns, 'renamed'), false, 'Reflect.deleteProperty: renamed' +); +assert.sameValue(ns.renamed, 'TC39', 'binding unmodified: renamed'); + +assert.throws(TypeError, function() { + delete ns.indirect; +}, 'delete: indirect'); +assert.sameValue( + Reflect.deleteProperty(ns, 'indirect'), + false, + 'Reflect.deleteProperty: indirect' +); +assert.sameValue(ns.indirect, 'Test262', 'binding unmodified: indirect'); diff --git a/src/dynamic-import/ns-delete-non-exported-no-strict.case b/src/dynamic-import/ns-delete-non-exported-no-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..d7efe56594410f456876085ef8bd9915d4444e9a --- /dev/null +++ b/src/dynamic-import/ns-delete-non-exported-no-strict.case @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-delete-p +desc: > + The [[Delete]] behavior for a key that does not describe an exported binding +info: | + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryDelete(O, P). + 3. Let exports be O.[[Exports]]. + 4. If P is an element of exports, return false. + 5. Return true. +template: namespace +flags: [noStrict] +---*/ + +//- import +import('./empty_FIXTURE.js') +//- body +assert(delete ns.undef, 'delete: undef'); +assert(Reflect.deleteProperty(ns, 'undef'), 'Reflect.deleteProperty: undef'); + +assert(delete ns.default, 'delete: default'); +assert( + Reflect.deleteProperty(ns, 'default'), 'Reflect.deleteProperty: default' +); + +assert.sameValue(delete ns[Symbol.toStringTag], false, 'delete: Symbol.toStringTag'); +assert.sameValue( + Reflect.deleteProperty(ns, Symbol.toStringTag), false, + 'Reflect.deleteProperty: Symbol.toStringTag' +); + +var sym = Symbol('test262'); +assert(delete ns[sym], 'delete: symbol'); +assert(Reflect.deleteProperty(ns, sym), 'Reflect.deleteProperty: symbol'); diff --git a/src/dynamic-import/ns-delete-non-exported-strict.case b/src/dynamic-import/ns-delete-non-exported-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..0a819b800b820b54fbc455be0f5877e840f6850b --- /dev/null +++ b/src/dynamic-import/ns-delete-non-exported-strict.case @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-delete-p +desc: > + The [[Delete]] behavior for a key that does not describe an exported binding +info: | + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryDelete(O, P). + 3. Let exports be O.[[Exports]]. + 4. If P is an element of exports, return false. + 5. Return true. +template: namespace +flags: [onlyStrict] +---*/ + +//- import +import('./empty_FIXTURE.js') +//- body +assert(delete ns.undef, 'delete: undef'); +assert(Reflect.deleteProperty(ns, 'undef'), 'Reflect.deleteProperty: undef'); + +assert(delete ns.default, 'delete: default'); +assert( + Reflect.deleteProperty(ns, 'default'), 'Reflect.deleteProperty: default' +); + +assert.sameValue( + Reflect.deleteProperty(ns, Symbol.toStringTag), false, + 'Reflect.deleteProperty: Symbol.toStringTag' + ); +assert.throws(TypeError, function() { delete ns[Symbol.toStringTag]; }, 'delete: Symbol.toStringTag'); + +var sym = Symbol('test262'); +assert(delete ns[sym], 'delete: symbol'); +assert(Reflect.deleteProperty(ns, sym), 'Reflect.deleteProperty: symbol'); diff --git a/src/dynamic-import/ns-extensible.case b/src/dynamic-import/ns-extensible.case new file mode 100644 index 0000000000000000000000000000000000000000..b54a0c88d625b28bb62825c5edd66d5e1fd443e8 --- /dev/null +++ b/src/dynamic-import/ns-extensible.case @@ -0,0 +1,12 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Module namespace objects are not extensible. +template: namespace +includes: [propertyHelper.js] +---*/ + +//- import +import('./module-code_FIXTURE.js') +//- body +assert.sameValue(Object.isExtensible(ns), false); diff --git a/src/dynamic-import/ns-get-nested-namespace-dflt-direct.case b/src/dynamic-import/ns-get-nested-namespace-dflt-direct.case new file mode 100644 index 0000000000000000000000000000000000000000..f8c524f34871dee71532e371fdd00a09fc4af50b --- /dev/null +++ b/src/dynamic-import/ns-get-nested-namespace-dflt-direct.case @@ -0,0 +1,60 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Direct Default exports are included in an imported module namespace object when + a namespace object is created. +esid: sec-module-namespace-exotic-objects-get-p-receiver +info: | + [...] + 6. Let binding be ! m.ResolveExport(P, « »). + 7. Assert: binding is a ResolvedBinding Record. + 8. Let targetModule be binding.[[Module]]. + 9. Assert: targetModule is not undefined. + 10. If binding.[[BindingName]] is "*namespace*", then + 11. Return ? GetModuleNamespace(targetModule). + + Runtime Semantics: GetModuleNamespace + [...] + 3. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, + i. Let resolution be ? module.ResolveExport(name, « », « »). + ii. If resolution is null, throw a SyntaxError exception. + iii. If resolution is not "ambiguous", append name to + unambiguousNames. + d. Let namespace be ModuleNamespaceCreate(module, unambiguousNames). + [...] +features: [export-star-as-namespace-from-module] +template: namespace +---*/ + +//- import +import('./get-nested-namespace-dflt-skip-prod_FIXTURE.js') +//- body +var desc = Object.getOwnPropertyDescriptor(ns, 'productionNS2'); + +assert.sameValue(desc.enumerable, true, 'ns.productionNS2: is enumerable'); +assert.sameValue(desc.writable, true, 'ns.productionNS2: is writable'); +assert.sameValue(desc.configurable, false, 'ns.productionNS2: is non-configurable'); + +var keys = Object.keys(ns.productionNS2); + +assert.sameValue(keys.length, 2); +assert.sameValue(keys[0], 'default'); +assert.sameValue(keys[1], 'productionOther'); + +desc = Object.getOwnPropertyDescriptor(ns.productionNS2, 'productionOther'); + +assert.sameValue(desc.value, null, 'ns.productionNS2.productionOther: value is null'); +assert.sameValue(desc.enumerable, true, 'ns.productionNS2.productionOther: is enumerable'); +assert.sameValue(desc.writable, true, 'ns.productionNS2.productionOther: is writable'); +assert.sameValue(desc.configurable, false, 'ns.productionNS2.productionOther: is non-configurable'); + +desc = Object.getOwnPropertyDescriptor(ns.productionNS2, 'default'); + +assert.sameValue(desc.value, 42, 'ns.productionNS2.default value is 42'); +assert.sameValue(desc.enumerable, true, 'ns.productionNS2.default is enumerable'); +assert.sameValue(desc.writable, true, 'ns.productionNS2.default is writable'); +assert.sameValue(desc.configurable, false, 'ns.productionNS2.default is non-configurable'); diff --git a/src/dynamic-import/ns-get-nested-namespace-dflt-indirect.case b/src/dynamic-import/ns-get-nested-namespace-dflt-indirect.case new file mode 100644 index 0000000000000000000000000000000000000000..f928107162a9044ed174b732e987295d62cd401b --- /dev/null +++ b/src/dynamic-import/ns-get-nested-namespace-dflt-indirect.case @@ -0,0 +1,61 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Inirect Default exports are included in an imported module namespace object when + a namespace object is created. +esid: sec-module-namespace-exotic-objects-get-p-receiver +info: | + [...] + 6. Let binding be ! m.ResolveExport(P, « »). + 7. Assert: binding is a ResolvedBinding Record. + 8. Let targetModule be binding.[[Module]]. + 9. Assert: targetModule is not undefined. + 10. If binding.[[BindingName]] is "*namespace*", then + 11. Return ? GetModuleNamespace(targetModule). + + Runtime Semantics: GetModuleNamespace + [...] + 3. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, + i. Let resolution be ? module.ResolveExport(name, « », « »). + ii. If resolution is null, throw a SyntaxError exception. + iii. If resolution is not "ambiguous", append name to + unambiguousNames. + d. Let namespace be ModuleNamespaceCreate(module, unambiguousNames). + [...] +flags: [module] +features: [export-star-as-namespace-from-module] +template: namespace +---*/ + +//- import +import('./get-nested-namespace-dflt-skip-named_FIXTURE.js') +//- body +var desc = Object.getOwnPropertyDescriptor(ns, 'namedNS2'); + +assert.sameValue(desc.enumerable, true, 'ns.namedNS2: is enumerable'); +assert.sameValue(desc.writable, true, 'ns.namedNS2: is writable'); +assert.sameValue(desc.configurable, false, 'ns.namedNS2: is non-configurable'); + +var keys = Object.keys(ns.namedNS2); + +assert.sameValue(keys.length, 2); +assert.sameValue(keys[0], 'default'); +assert.sameValue(keys[1], 'namedOther'); + +desc = Object.getOwnPropertyDescriptor(ns.namedNS2, 'namedOther'); + +assert.sameValue(desc.value, null, 'ns.namedNS2.namedOther value is null'); +assert.sameValue(desc.enumerable, true, 'ns.namedNS2.namedOther: is enumerable'); +assert.sameValue(desc.writable, true, 'ns.namedNS2.namedOther: is writable'); +assert.sameValue(desc.configurable, false, 'ns.namedNS2.namedOther: is non-configurable'); + +desc = Object.getOwnPropertyDescriptor(ns.namedNS2, 'default'); + +assert.sameValue(desc.value, 42, 'ns.namedNS2.default value is 42'); +assert.sameValue(desc.enumerable, true, 'ns.namedNS2.default is enumerable'); +assert.sameValue(desc.writable, true, 'ns.namedNS2.default is writable'); +assert.sameValue(desc.configurable, false, 'ns.namedNS2.default is non-configurable'); diff --git a/src/dynamic-import/ns-get-nested-namespace-props-nrml.case b/src/dynamic-import/ns-get-nested-namespace-props-nrml.case new file mode 100644 index 0000000000000000000000000000000000000000..16ed8ef6f968c62330d1f5bc1856756706ce1566 --- /dev/null +++ b/src/dynamic-import/ns-get-nested-namespace-props-nrml.case @@ -0,0 +1,58 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Module namespace object reports properties for all ExportEntries of all + dependencies. +esid: sec-moduledeclarationinstantiation +info: | + [...] + 12. For each ImportEntry Record in in module.[[ImportEntries]], do + a. Let importedModule be ? HostResolveImportedModule(module, + in.[[ModuleRequest]]). + b. If in.[[ImportName]] is "*", then + i. Let namespace be ? GetModuleNamespace(importedModule). + [...] + + Runtime Semantics: GetModuleNamespace + 3. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, + i. Let resolution be ? module.ResolveExport(name, « », « »). + ii. If resolution is null, throw a SyntaxError exception. + iii. If resolution is not "ambiguous", append name to + unambiguousNames. + d. Let namespace be ModuleNamespaceCreate(module, unambiguousNames). +features: [export-star-as-namespace-from-module] +template: namespace +---*/ + +//- setup +function hasOwnProperty(obj, property) { + return Object.prototype.hasOwnProperty.call(obj, property); +} + +//- import +import('./get-nested-namespace-props-nrml-1_FIXTURE.js') +//- body +// Export entries defined by a re-exported as exportns module +assert(hasOwnProperty(ns.exportns, 'starAsVarDecl'), 'starssVarDecl'); +assert(hasOwnProperty(ns.exportns, 'starAsLetDecl'), 'starSsLetDecl'); +assert(hasOwnProperty(ns.exportns, 'starAsConstDecl'), 'starSsConstDecl'); +assert(hasOwnProperty(ns.exportns, 'starAsFuncDecl'), 'starAsFuncDecl'); +assert(hasOwnProperty(ns.exportns, 'starAsGenDecl'), 'starAsGenDecl'); +assert(hasOwnProperty(ns.exportns, 'starAsClassDecl'), 'starAsClassDecl'); +assert(hasOwnProperty(ns.exportns, 'starAsBindingId'), 'starAsBindingId'); +assert(hasOwnProperty(ns.exportns, 'starIdName'), 'starIdName'); +assert(hasOwnProperty(ns.exportns, 'starAsIndirectIdName'), 'starAsIndirectIdName'); +assert(hasOwnProperty(ns.exportns, 'starAsIndirectIdName2'), 'starAsIndirectIdName2'); +assert(hasOwnProperty(ns.exportns, 'namespaceBinding'), 'namespaceBinding'); + +// Bindings that were not exported from any module +assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedVar'), false, 'nonExportedVar'); +assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedLet'), false, 'nonExportedLet'); +assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedConst'), false, 'nonExportedConst'); +assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedFunc'), false, 'nonExportedFunc'); +assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedGen'), false, 'nonExportedGen'); +assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedClass'), false, 'nonExportedClass'); diff --git a/src/dynamic-import/ns-get-own-property-str-found-init.case b/src/dynamic-import/ns-get-own-property-str-found-init.case new file mode 100644 index 0000000000000000000000000000000000000000..3d67db2bbcf5ef577ff4e3bf72ebaa71577eb109 --- /dev/null +++ b/src/dynamic-import/ns-get-own-property-str-found-init.case @@ -0,0 +1,58 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-getownproperty-p +desc: > + Behavior of the [[GetOwnProperty]] internal method with a string argument + describing an initialized binding +info: | + 1. If Type(P) is Symbol, return OrdinaryGetOwnProperty(O, P). + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is not an element of exports, return undefined. + 4. Let value be ? O.[[Get]](P, O). + 5. Return PropertyDescriptor{[[Value]]: value, [[Writable]]: true, + [[Enumerable]]: true, [[Configurable]]: false }. +template: namespace +---*/ + +//- import +import('./module-code_FIXTURE.js') +//- body +var desc; + +assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'local1'), true +); +desc = Object.getOwnPropertyDescriptor(ns, 'local1'); +assert.sameValue(desc.value, 'Test262'); +assert.sameValue(desc.enumerable, true, 'local1 enumerable'); +assert.sameValue(desc.writable, true, 'local1 writable'); +assert.sameValue(desc.configurable, false, 'local1 configurable'); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'renamed'), true +); +desc = Object.getOwnPropertyDescriptor(ns, 'renamed'); +assert.sameValue(desc.value, 'TC39'); +assert.sameValue(desc.enumerable, true, 'renamed enumerable'); +assert.sameValue(desc.writable, true, 'renamed writable'); +assert.sameValue(desc.configurable, false, 'renamed configurable'); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'indirect'), true +); +desc = Object.getOwnPropertyDescriptor(ns, 'indirect'); +assert.sameValue(desc.value, 'Test262'); +assert.sameValue(desc.enumerable, true, 'indirect enumerable'); +assert.sameValue(desc.writable, true, 'indirect writable'); +assert.sameValue(desc.configurable, false, 'indirect configurable'); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'default'), true +); +desc = Object.getOwnPropertyDescriptor(ns, 'default'); +assert.sameValue(desc.value, 42); +assert.sameValue(desc.enumerable, true, 'default enumerable'); +assert.sameValue(desc.writable, true, 'default writable'); +assert.sameValue(desc.configurable, false, 'default configurable'); diff --git a/src/dynamic-import/ns-get-own-property-str-not-found.case b/src/dynamic-import/ns-get-own-property-str-not-found.case new file mode 100644 index 0000000000000000000000000000000000000000..350aa004052376f79d3b3fd6516ba8cd4962b095 --- /dev/null +++ b/src/dynamic-import/ns-get-own-property-str-not-found.case @@ -0,0 +1,51 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-getownproperty-p +desc: > + Behavior of the [[GetOwnProperty]] internal method with a string argument + describing a binding that cannot be found +info: | + 1. If Type(P) is Symbol, return OrdinaryGetOwnProperty(O, P). + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is not an element of exports, return undefined. +template: namespace +---*/ + +//- import +import('./module-code_FIXTURE.js') +//- body +var desc; + +assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'local2'), + false, + 'hasOwnProperty: local2' +); +desc = Object.getOwnPropertyDescriptor(ns, 'local2'); +assert.sameValue(desc, undefined, 'property descriptor for "local2"'); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'toStringTag'), + false, + 'hasOwnProperty: toStringTag' +); +desc = Object.getOwnPropertyDescriptor(ns, 'toStringTag'); +assert.sameValue(desc, undefined, 'property descriptor for "toStringTag"'); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'iterator'), + false, + 'hasOwnProperty: iterator' +); +desc = Object.getOwnPropertyDescriptor(ns, 'iterator'); +assert.sameValue(desc, undefined, 'property descriptor for "iterator"'); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, '__proto__'), + false, + 'hasOwnProperty: __proto__' +); +desc = Object.getOwnPropertyDescriptor(ns, '__proto__'); +assert.sameValue(desc, undefined, 'property descriptor for "__proto__"'); diff --git a/src/dynamic-import/ns-get-own-property-sym.case b/src/dynamic-import/ns-get-own-property-sym.case new file mode 100644 index 0000000000000000000000000000000000000000..e84169d34bfc278c3f9278215f038a40a9c06256 --- /dev/null +++ b/src/dynamic-import/ns-get-own-property-sym.case @@ -0,0 +1,31 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-getownproperty-p +desc: > + Behavior of the [[GetOwnProperty]] internal method with a Symbol argument +features: [Symbol, Symbol.toStringTag] +template: namespace +---*/ + +//- setup +var notFound = Symbol('test262'); + +//- import +import('./module-code_FIXTURE.js') +//- body +var desc; + +assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, Symbol.toStringTag), true +); +desc = Object.getOwnPropertyDescriptor(ns, Symbol.toStringTag); +assert.sameValue(desc.value, ns[Symbol.toStringTag]); +assert.sameValue(desc.enumerable, false, 'Symbol.toStringTag enumerable'); +assert.sameValue(desc.writable, false, 'Symbol.toStringTag writable'); +assert.sameValue(desc.configurable, false, 'Symbol.toStringTag configurable'); + +assert.sameValue(Object.prototype.hasOwnProperty.call(ns, notFound), false); +desc = Object.getOwnPropertyDescriptor(ns, notFound); +assert.sameValue(desc, undefined); diff --git a/src/dynamic-import/ns-get-str-found.case b/src/dynamic-import/ns-get-str-found.case new file mode 100644 index 0000000000000000000000000000000000000000..5f26725bc3e80fe61d94a392ad13c4fdb756838d --- /dev/null +++ b/src/dynamic-import/ns-get-str-found.case @@ -0,0 +1,22 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-get-p-receiver +desc: > + Behavior of the [[Get]] internal method with a string argument for exported + initialized bindings. +info: | + [...] + 12. Let targetEnvRec be targetEnv's EnvironmentRecord. + 13. Return ? targetEnvRec.GetBindingValue(binding.[[BindingName]], true). +template: namespace +---*/ + +//- import +import('./module-code_FIXTURE.js') +//- body +assert.sameValue(ns.local1, 'Test262'); +assert.sameValue(ns.renamed, 'TC39'); +assert.sameValue(ns.indirect, 'Test262'); +assert.sameValue(ns.default, 42); diff --git a/src/dynamic-import/ns-get-str-not-found.case b/src/dynamic-import/ns-get-str-not-found.case new file mode 100644 index 0000000000000000000000000000000000000000..9cf702cdbfda93d0447ab8f304612b8aa7eea1cd --- /dev/null +++ b/src/dynamic-import/ns-get-str-not-found.case @@ -0,0 +1,25 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-get-p-receiver +desc: > + Behavior of the [[Get]] internal method with a string argument for + non-exported bindings +info: | + [...] + 3. Let exports be the value of O's [[Exports]] internal slot. + 4. If P is not an element of exports, return undefined. +template: namespace +---*/ + +//- setup +var local2; // not used + +//- import +import('./module-code_FIXTURE.js') +//- body +assert.sameValue(ns.local2, undefined, 'key: local2'); +assert.sameValue(ns.toStringTag, undefined, 'key: toStringTag'); +assert.sameValue(ns.iterator, undefined, 'key: iterator'); +assert.sameValue(ns.__proto__, undefined, 'key: __proto__'); diff --git a/src/dynamic-import/ns-get-sym-found.case b/src/dynamic-import/ns-get-sym-found.case new file mode 100644 index 0000000000000000000000000000000000000000..49f2daeb3186f4aac4bfa69cfb3e84280675220e --- /dev/null +++ b/src/dynamic-import/ns-get-sym-found.case @@ -0,0 +1,20 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-get-p-receiver +desc: > + Behavior of the [[Get]] internal method with a symbol argument that can be + found +info: | + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryGet(O, P, Receiver). +features: [Symbol.toStringTag] +template: namespace +---*/ + +//- import +import('./module-code_FIXTURE.js') +//- body +assert.sameValue(typeof ns[Symbol.toStringTag], 'string'); diff --git a/src/dynamic-import/ns-get-sym-not-found.case b/src/dynamic-import/ns-get-sym-not-found.case new file mode 100644 index 0000000000000000000000000000000000000000..38e146f3369f70fd1b2a0fd89857f7677a8052fd --- /dev/null +++ b/src/dynamic-import/ns-get-sym-not-found.case @@ -0,0 +1,20 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-get-p-receiver +desc: > + Behavior of the [[Get]] internal method with a symbol argument that cannot + be found +info: | + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryGet(O, P, Receiver). +features: [Symbol] +template: namespace +---*/ + +//- import +import('./module-code_FIXTURE.js') +//- body +assert.sameValue(ns[Symbol('test262')], undefined, 'Symbol: test262'); diff --git a/src/dynamic-import/ns-has-property-str-found-init.case b/src/dynamic-import/ns-has-property-str-found-init.case new file mode 100644 index 0000000000000000000000000000000000000000..3a713efda18c39f4901d86d7dc1aa35a7cf43195 --- /dev/null +++ b/src/dynamic-import/ns-has-property-str-found-init.case @@ -0,0 +1,29 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-hasproperty-p +desc: > + Behavior of the [[HasProperty]] internal method with a string argument for + exported initialized bindings. +info: | + [...] + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is an element of exports, return true. +template: namespace +---*/ + +//- import +import('./module-code_FIXTURE.js') +//- body +assert('local1' in ns, 'in: local1'); +assert(Reflect.has(ns, 'local1'), 'Reflect.has: local1'); + +assert('renamed' in ns, 'in: renamed'); +assert(Reflect.has(ns, 'renamed'), 'Reflect.has: renamed'); + +assert('indirect' in ns, 'in: indirect'); +assert(Reflect.has(ns, 'indirect'), 'Reflect.has: indirect'); + +assert('default' in ns, 'in: default'); +assert(Reflect.has(ns, 'default'), 'Reflect.has: default'); diff --git a/src/dynamic-import/ns-has-property-str-not-found.case b/src/dynamic-import/ns-has-property-str-not-found.case new file mode 100644 index 0000000000000000000000000000000000000000..5d64a62270ace345679817110cc873b74e2739f7 --- /dev/null +++ b/src/dynamic-import/ns-has-property-str-not-found.case @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-hasproperty-p +desc: > + Behavior of the [[HasProperty]] internal method with a string argument for + non-exported bindings +info: | + [...] + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is an element of exports, return true. + 4. Return false. +template: namespace +---*/ + +//- setup +var local2; // not used + +//- import +import('./module-code_FIXTURE.js') +//- body +assert.sameValue('local2' in ns, false, 'in: local2'); +assert.sameValue(Reflect.has(ns, 'local2'), false, 'Reflect.has: local2'); + +assert.sameValue('toStringTag' in ns, false, 'in: toStringTag'); +assert.sameValue( + Reflect.has(ns, 'toStringTag'), false, 'Reflect.has: toStringTag' +); + +assert.sameValue('iterator' in ns, false, 'in: iterator'); +assert.sameValue(Reflect.has(ns, 'iterator'), false, 'Reflect.has: iterator'); + +assert.sameValue('__proto__' in ns, false, 'in: __proto__'); +assert.sameValue( + Reflect.has(ns, '__proto__'), false, 'Reflect.has: __proto__' +); diff --git a/src/dynamic-import/ns-has-property-sym-found.case b/src/dynamic-import/ns-has-property-sym-found.case new file mode 100644 index 0000000000000000000000000000000000000000..e3e8f33f05276b2767a32423302a94e02df624ce --- /dev/null +++ b/src/dynamic-import/ns-has-property-sym-found.case @@ -0,0 +1,19 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-hasproperty-p +desc: > + Behavior of the [[HasProperty]] internal method with a symbol argument that + can be found +info: | + 1. If Type(P) is Symbol, return OrdinaryHasProperty(O, P). +features: [Symbol.toStringTag] +template: namespace +---*/ + +//- import +import('./module-code_FIXTURE.js') +//- body +assert(Symbol.toStringTag in ns, 'in: Symbol.toStringTag'); +assert(Reflect.has(ns, Symbol.toStringTag), 'Reflect.has: Symbol.toStringTag'); diff --git a/src/dynamic-import/ns-has-property-sym-not-found.case b/src/dynamic-import/ns-has-property-sym-not-found.case new file mode 100644 index 0000000000000000000000000000000000000000..5f1e050e42415cd0b3ec16adebf359dcd2dd8b72 --- /dev/null +++ b/src/dynamic-import/ns-has-property-sym-not-found.case @@ -0,0 +1,22 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-hasproperty-p +desc: > + Behavior of the [[HasProperty]] internal method with a symbol argument that + cannot be found +info: | + 1. If Type(P) is Symbol, return OrdinaryHasProperty(O, P). +features: [Symbol] +template: namespace +---*/ + +//- setup +var sym = Symbol('test262'); + +//- import +import('./module-code_FIXTURE.js') +//- body +assert.sameValue(sym in ns, false, 'in'); +assert.sameValue(Reflect.has(ns, sym), false, 'Reflect.has'); diff --git a/src/dynamic-import/ns-no-iterator.case b/src/dynamic-import/ns-no-iterator.case new file mode 100644 index 0000000000000000000000000000000000000000..9e082e3c113d165582ac95ed4bfad58f412fb084 --- /dev/null +++ b/src/dynamic-import/ns-no-iterator.case @@ -0,0 +1,13 @@ +// Copyright (C) 2016 Kevin Gibbons. All rights reserved. +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Module namespace objects lack a Symbol.toStringTag +template: namespace +features: [Symbol.iterator] +---*/ + +//- import +import('./module-code_FIXTURE.js') +//- body +assert.sameValue(Object.prototype.hasOwnProperty.call(ns, Symbol.iterator), false); diff --git a/src/dynamic-import/ns-own-property-keys-sort.case b/src/dynamic-import/ns-own-property-keys-sort.case new file mode 100644 index 0000000000000000000000000000000000000000..b946b02af5cdea90688aa6136daf297deebea192 --- /dev/null +++ b/src/dynamic-import/ns-own-property-keys-sort.case @@ -0,0 +1,64 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-ownpropertykeys +desc: > + The [[OwnPropertyKeys]] internal method reflects the sorted order +info: | + 1. Let exports be a copy of the value of O's [[Exports]] internal slot. + 2. Let symbolKeys be ! OrdinaryOwnPropertyKeys(O). + 3. Append all the entries of symbolKeys to the end of exports. + 4. Return exports. +features: [Symbol.toStringTag] +template: namespace +---*/ + +//- import +import('./own-keys-sort_FIXTURE.js') +//- body +var stringKeys = Object.getOwnPropertyNames(ns); + +assert.sameValue(stringKeys.length, 16); +assert.sameValue(stringKeys[0], '$', 'stringKeys[0] === "$"'); +assert.sameValue(stringKeys[1], '$$', 'stringKeys[1] === "$$"'); +assert.sameValue(stringKeys[2], 'A', 'stringKeys[2] === "A"'); +assert.sameValue(stringKeys[3], 'Z', 'stringKeys[3] === "Z"'); +assert.sameValue(stringKeys[4], '_', 'stringKeys[4] === "_"'); +assert.sameValue(stringKeys[5], '__', 'stringKeys[5] === "__"'); +assert.sameValue(stringKeys[6], 'a', 'stringKeys[6] === "a"'); +assert.sameValue(stringKeys[7], 'aa', 'stringKeys[7] === "aa"'); +assert.sameValue(stringKeys[8], 'az', 'stringKeys[8] === "az"'); +assert.sameValue(stringKeys[9], 'default', 'stringKeys[9] === "default"'); +assert.sameValue(stringKeys[10], 'z', 'stringKeys[10] === "z"'); +assert.sameValue(stringKeys[11], 'za', 'stringKeys[11] === "za"'); +assert.sameValue(stringKeys[12], 'zz', 'stringKeys[12] === "zz"'); +assert.sameValue(stringKeys[13], '\u03bb', 'stringKeys[13] === "\u03bb"'); +assert.sameValue(stringKeys[14], '\u03bc', 'stringKeys[14] === "\u03bc"'); +assert.sameValue(stringKeys[15], '\u03c0', 'stringKeys[15] === "\u03c0"'); + +var allKeys = Reflect.ownKeys(ns); +assert( + allKeys.length >= 17, + 'at least as many keys as defined by the module and the specification' +); +assert.sameValue(allKeys[0], '$', 'allKeys[0] === "$"'); +assert.sameValue(allKeys[1], '$$', 'allKeys[1] === "$$"'); +assert.sameValue(allKeys[2], 'A', 'allKeys[2] === "A"'); +assert.sameValue(allKeys[3], 'Z', 'allKeys[3] === "Z"'); +assert.sameValue(allKeys[4], '_', 'allKeys[4] === "_"'); +assert.sameValue(allKeys[5], '__', 'allKeys[5] === "__"'); +assert.sameValue(allKeys[6], 'a', 'allKeys[6] === "a"'); +assert.sameValue(allKeys[7], 'aa', 'allKeys[7] === "aa"'); +assert.sameValue(allKeys[8], 'az', 'allKeys[8] === "az"'); +assert.sameValue(allKeys[9], 'default', 'allKeys[9] === "default"'); +assert.sameValue(allKeys[10], 'z', 'allKeys[10] === "z"'); +assert.sameValue(allKeys[11], 'za', 'allKeys[11] === "za"'); +assert.sameValue(allKeys[12], 'zz', 'allKeys[12] === "zz"'); +assert.sameValue(allKeys[13], '\u03bb', 'allKeys[13] === "\u03bb"'); +assert.sameValue(allKeys[14], '\u03bc', 'allKeys[14] === "\u03bc"'); +assert.sameValue(allKeys[15], '\u03c0', 'allKeys[15] === "\u03c0"'); +assert( + allKeys.indexOf(Symbol.toStringTag) > 15, + 'keys array includes Symbol.toStringTag' +); diff --git a/src/dynamic-import/ns-prevent-extensions-object.case b/src/dynamic-import/ns-prevent-extensions-object.case new file mode 100644 index 0000000000000000000000000000000000000000..bd1053066d463bb9b5b19e0443e519394fbeb0d1 --- /dev/null +++ b/src/dynamic-import/ns-prevent-extensions-object.case @@ -0,0 +1,16 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-preventextensions +desc: The [[PreventExtensions]] internal method returns `true` +template: namespace +---*/ + +//- import +import('./empty_FIXTURE.js') +//- body +// This invocation should not throw an exception +Object.preventExtensions(ns); + +assert.sameValue(Reflect.preventExtensions(ns), true); diff --git a/src/dynamic-import/ns-prevent-extensions-reflect.case b/src/dynamic-import/ns-prevent-extensions-reflect.case new file mode 100644 index 0000000000000000000000000000000000000000..4b54b3fa1304a435f075aba767db255c33728758 --- /dev/null +++ b/src/dynamic-import/ns-prevent-extensions-reflect.case @@ -0,0 +1,13 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-preventextensions +desc: The [[PreventExtensions]] internal method returns `true` +template: namespace +---*/ + +//- import +import('./empty_FIXTURE.js') +//- body +assert.sameValue(Reflect.preventExtensions(ns), true); diff --git a/src/dynamic-import/ns-prop-descs.case b/src/dynamic-import/ns-prop-descs.case new file mode 100644 index 0000000000000000000000000000000000000000..9bb34d9d86ffeaca9d93cebac6e7ef0b42f20b97 --- /dev/null +++ b/src/dynamic-import/ns-prop-descs.case @@ -0,0 +1,41 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: imported object properties descriptors +template: namespace +---*/ + +//- import +import('./module-code_FIXTURE.js') +//- body +// propertyHelper.js is not appropriate for this test because it assumes that +// the object exposes the ordinary object's implementation of [[Get]], [[Set]], +// [[Delete]], and [[OwnPropertyKeys]], which the module namespace exotic +// object does not. +var desc = Object.getOwnPropertyDescriptor(ns, 'default'); + +assert.sameValue(desc.value, 42, 'default: value is 42'); +assert.sameValue(desc.enumerable, true, 'default: is enumerable'); +assert.sameValue(desc.writable, true, 'default: is writable'); +assert.sameValue(desc.configurable, false, 'default: is non-configurable'); + +desc = Object.getOwnPropertyDescriptor(ns, 'local1'); + +assert.sameValue(desc.value, 'Test262', 'local1: value is "Test262"'); +assert.sameValue(desc.enumerable, true, 'local1: is enumerable'); +assert.sameValue(desc.writable, true, 'local1: is writable'); +assert.sameValue(desc.configurable, false, 'local1: is non-configurable'); + +desc = Object.getOwnPropertyDescriptor(ns, 'renamed'); + +assert.sameValue(desc.value, 'TC39', 'renamed: value is TC39"'); +assert.sameValue(desc.enumerable, true, 'renamed: is enumerable'); +assert.sameValue(desc.writable, true, 'renamed: is writable'); +assert.sameValue(desc.configurable, false, 'renamed: is non-configurable'); + +desc = Object.getOwnPropertyDescriptor(ns, 'indirect'); + +assert.sameValue(desc.value, 'Test262', 'indirect: value is Test262"'); +assert.sameValue(desc.enumerable, true, 'indirect: is enumerable'); +assert.sameValue(desc.writable, true, 'indirect: is writable'); +assert.sameValue(desc.configurable, false, 'indirect: is non-configurable'); diff --git a/src/dynamic-import/ns-prototype.case b/src/dynamic-import/ns-prototype.case new file mode 100644 index 0000000000000000000000000000000000000000..d10f33b6d7d911515eb7c9724252714c5a5a0833 --- /dev/null +++ b/src/dynamic-import/ns-prototype.case @@ -0,0 +1,12 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Module namespace object prototype is null +template: namespace +---*/ + +//- import +import('./module-code_FIXTURE.js') +//- body +assert.sameValue(ns instanceof Object, false); +assert.sameValue(Object.getPrototypeOf(ns), null, 'prototype is null'); diff --git a/src/dynamic-import/ns-set-no-strict.case b/src/dynamic-import/ns-set-no-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..842e8cac7d27359c70124136a46e6e13d0368cc0 --- /dev/null +++ b/src/dynamic-import/ns-set-no-strict.case @@ -0,0 +1,43 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-set-p-v-receiver +desc: The [[Set]] internal method consistently returns `false`, No Strict Mode +info: | + 1. Return false. +features: [Symbol, Symbol.toStringTag] +template: namespace +flags: [noStrict] +---*/ + +//- setup +var sym = Symbol('test262'); + +//- import +import('./module-code_FIXTURE.js') +//- body +assert.sameValue(Reflect.set(ns, 'local1'), false, 'Reflect.set: local1'); +assert.sameValue(ns.local1 = null, null, 'AssignmentExpression: local1'); + +assert.sameValue(Reflect.set(ns, 'local2'), false, 'Reflect.set: local2'); +assert.sameValue(ns.local2 = null, null, 'AssignmentExpression: local2'); + +assert.sameValue(Reflect.set(ns, 'renamed'), false, 'Reflect.set: renamed'); +assert.sameValue(ns.renamed = null, null, 'AssignmentExpression: renamed'); + +assert.sameValue(Reflect.set(ns, 'indirect'), false, 'Reflect.set: indirect'); +assert.sameValue(ns.indirect = null, null, 'AssignmentExpression: indirect'); + +assert.sameValue(Reflect.set(ns, 'default'), false, 'Reflect.set: default'); +assert.sameValue(ns.default = null, null, 'AssignmentExpression: default'); + +assert.sameValue( + Reflect.set(ns, Symbol.toStringTag, null), + false, + 'Reflect.set: Symbol.toStringTag' +); +assert.sameValue(ns[Symbol.toStringTag] = null, null, 'AssignmentExpression: Symbol.toStringTag'); + +assert.sameValue(Reflect.set(ns, sym), false, 'Reflect.set: sym'); +assert.sameValue(ns[sym] = null, null, 'AssignmentExpression: sym'); diff --git a/src/dynamic-import/ns-set-prototype-of-null.case b/src/dynamic-import/ns-set-prototype-of-null.case new file mode 100644 index 0000000000000000000000000000000000000000..4ff405490917c71ac2cc7724f69ae1644c0de178 --- /dev/null +++ b/src/dynamic-import/ns-set-prototype-of-null.case @@ -0,0 +1,16 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-setprototypeof-v +desc: > + The [[SetPrototypeOf]] internal method returns `true` if + passed `null` +template: namespace +---*/ + +//- import +import('./empty_FIXTURE.js') +//- body +assert.sameValue(typeof Object.setPrototypeOf, 'function'); +assert.sameValue(ns, Object.setPrototypeOf(ns, null)); diff --git a/src/dynamic-import/ns-set-prototype-of.case b/src/dynamic-import/ns-set-prototype-of.case new file mode 100644 index 0000000000000000000000000000000000000000..c1926fa94789265e31aab0ab54cac8fd557c9a9e --- /dev/null +++ b/src/dynamic-import/ns-set-prototype-of.case @@ -0,0 +1,19 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-setprototypeof +desc: The [[SetPrototypeOf]] internal method returns `false` +template: namespace +---*/ + +//- import +import('./module-code_FIXTURE.js') +//- body +var newProto = {}; + +assert.sameValue(typeof Object.setPrototypeOf, 'function'); + +assert.throws(TypeError, function() { + Object.setPrototypeOf(ns, newProto); +}); diff --git a/src/dynamic-import/ns-set-same-values-no-strict.case b/src/dynamic-import/ns-set-same-values-no-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..e8ed24ffb5aa2e747d9a8b86e6b8b1b7eede7ec3 --- /dev/null +++ b/src/dynamic-import/ns-set-same-values-no-strict.case @@ -0,0 +1,36 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-set-p-v-receiver +desc: > + The [[Set]] internal method consistently returns `false` even setting + the same value - No Strict Mode +info: | + 1. Return false. +features: [Symbol, Symbol.toStringTag] +template: namespace +flags: [noStrict] +---*/ + +//- import +import('./module-code_FIXTURE.js') +//- body +assert.sameValue(Reflect.set(ns, 'local1', 'Test262'), false, 'Reflect.set: local1'); +assert.sameValue(ns.local1 = 'Test262', 'Test262', 'AssignmentExpression: local1'); + +assert.sameValue(Reflect.set(ns, 'renamed', 'TC39'), false, 'Reflect.set: renamed'); +assert.sameValue(ns.renamed = 'TC39', 'TC39', 'AssignmentExpression: renamed'); + +assert.sameValue(Reflect.set(ns, 'indirect', 'Test262'), false, 'Reflect.set: indirect'); +assert.sameValue(ns.indirect = 'Test262', 'Test262', 'AssignmentExpression: indirect'); + +assert.sameValue(Reflect.set(ns, 'default', 42), false, 'Reflect.set: default'); +assert.sameValue(ns.default = 42, 42, 'AssignmentExpression: default'); + +assert.sameValue( + Reflect.set(ns, Symbol.toStringTag, ns[Symbol.toStringTag]), + false, + 'Reflect.set: Symbol.toStringTag' +); +assert.sameValue(ns[Symbol.toStringTag] = ns[Symbol.toStringTag], 'Module', 'AssignmentExpression: Symbol.toStringTag'); diff --git a/src/dynamic-import/ns-set-same-values-strict.case b/src/dynamic-import/ns-set-same-values-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..126ef0f95eae5b9b8512b492727c71f4f034d553 --- /dev/null +++ b/src/dynamic-import/ns-set-same-values-strict.case @@ -0,0 +1,46 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-set-p-v-receiver +desc: > + The [[Set]] internal method consistently returns `false` even setting + the same value - Strict Mode +info: | + 1. Return false. +features: [Symbol, Symbol.toStringTag] +template: namespace +flags: [onlyStrict] +---*/ + +//- import +import('./module-code_FIXTURE.js') +//- body +assert.sameValue(Reflect.set(ns, 'local1', 'Test262'), false, 'Reflect.set: local1'); +assert.throws(TypeError, function() { + ns.local1 = 'Test262'; +}, 'AssignmentExpression: local1'); + +assert.sameValue(Reflect.set(ns, 'renamed', 'TC39'), false, 'Reflect.set: renamed'); +assert.throws(TypeError, function() { + ns.renamed = 'TC39'; +}, 'AssignmentExpression: renamed'); + +assert.sameValue(Reflect.set(ns, 'indirect', 'Test262'), false, 'Reflect.set: indirect'); +assert.throws(TypeError, function() { + ns.indirect = 'Test262'; +}, 'AssignmentExpression: indirect'); + +assert.sameValue(Reflect.set(ns, 'default', 42), false, 'Reflect.set: default'); +assert.throws(TypeError, function() { + ns.default = 42; +}, 'AssignmentExpression: default'); + +assert.sameValue( + Reflect.set(ns, Symbol.toStringTag, ns[Symbol.toStringTag]), + false, + 'Reflect.set: Symbol.toStringTag' +); +assert.throws(TypeError, function() { + ns[Symbol.toStringTag] = ns[Symbol.toStringTag]; +}, 'AssignmentExpression: Symbol.toStringTag'); diff --git a/src/dynamic-import/ns-set-strict.case b/src/dynamic-import/ns-set-strict.case new file mode 100644 index 0000000000000000000000000000000000000000..136e6f79f00b2942fbd9ecfcc47b128a4d364bd3 --- /dev/null +++ b/src/dynamic-import/ns-set-strict.case @@ -0,0 +1,57 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-module-namespace-exotic-objects-set-p-v-receiver +desc: The [[Set]] internal method consistently returns `false`, Strict Mode +info: | + 1. Return false. +features: [Symbol, Symbol.toStringTag] +template: namespace +flags: [onlyStrict] +---*/ + +//- setup +var sym = Symbol('test262'); + +//- import +import('./module-code_FIXTURE.js') +//- body +assert.sameValue(Reflect.set(ns, 'local1'), false, 'Reflect.set: local1'); +assert.throws(TypeError, function() { + ns.local1 = null; +}, 'AssignmentExpression: local1'); + +assert.sameValue(Reflect.set(ns, 'local2'), false, 'Reflect.set: local2'); +assert.throws(TypeError, function() { + ns.local2 = null; +}, 'AssignmentExpression: local2'); + +assert.sameValue(Reflect.set(ns, 'renamed'), false, 'Reflect.set: renamed'); +assert.throws(TypeError, function() { + ns.renamed = null; +}, 'AssignmentExpression: renamed'); + +assert.sameValue(Reflect.set(ns, 'indirect'), false, 'Reflect.set: indirect'); +assert.throws(TypeError, function() { + ns.indirect = null; +}, 'AssignmentExpression: indirect'); + +assert.sameValue(Reflect.set(ns, 'default'), false, 'Reflect.set: default'); +assert.throws(TypeError, function() { + ns.default = null; +}, 'AssignmentExpression: default'); + +assert.sameValue( + Reflect.set(ns, Symbol.toStringTag, null), + false, + 'Reflect.set: Symbol.toStringTag' +); +assert.throws(TypeError, function() { + ns[Symbol.toStringTag] = null; +}, 'AssignmentExpression: Symbol.toStringTag'); + +assert.sameValue(Reflect.set(ns, sym), false, 'Reflect.set: sym'); +assert.throws(TypeError, function() { + ns[sym] = null; +}, 'AssignmentExpression: sym'); diff --git a/src/dynamic-import/returns-promise.case b/src/dynamic-import/returns-thenable.case similarity index 86% rename from src/dynamic-import/returns-promise.case rename to src/dynamic-import/returns-thenable.case index e03f674d3187a5f96a25f8d50a67e4f8a4be956c..f62fe389193bcedea10da89217c00615a3ce6de0 100644 --- a/src/dynamic-import/returns-promise.case +++ b/src/dynamic-import/returns-thenable.case @@ -2,7 +2,7 @@ // Copyright (C) 2018 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -desc: Dynamic import() returns a Promise object. +desc: Dynamic import() returns a thenable object. template: default ---*/ diff --git a/src/dynamic-import/script-code-valid.case b/src/dynamic-import/script-code-valid.case index 1c4f813a0668348a3b4518bbffe48eecb3790a54..8304af7ed252312ccfdaca0073bd83c135ce13ed 100644 --- a/src/dynamic-import/script-code-valid.case +++ b/src/dynamic-import/script-code-valid.case @@ -11,4 +11,4 @@ template: syntax/valid var smoosh; function smoosh() {} //- import -import('./script-code-valid.js') +import('./empty_FIXTURE.js') diff --git a/src/dynamic-import/specifier-tostring-abrupt-rejects.case b/src/dynamic-import/specifier-tostring-abrupt-rejects.case new file mode 100644 index 0000000000000000000000000000000000000000..7a67f6ea9e25f2a3ec33f6c65b8c93d5231c3832 --- /dev/null +++ b/src/dynamic-import/specifier-tostring-abrupt-rejects.case @@ -0,0 +1,36 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Abrupt from ToString(specifier) rejects the promise +esid: sec-moduleevaluation +info: | + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. +template: catch +---*/ + +//- setup +const obj = { + toString() { + throw 'custom error'; + } +}; + +//- import +import(obj) +//- body +assert.sameValue(error, 'custom error'); diff --git a/src/dynamic-import/specifier-tostring.case b/src/dynamic-import/specifier-tostring.case new file mode 100644 index 0000000000000000000000000000000000000000..d09cca31bdc93fb41e6d4d8be691d51452683a53 --- /dev/null +++ b/src/dynamic-import/specifier-tostring.case @@ -0,0 +1,38 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + ToString value of specifier +esid: sec-moduleevaluation +info: | + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. +template: default +---*/ + +//- setup +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + +//- import +import(obj) +//- body +assert.sameValue(imported.default, 42); +assert.sameValue(imported.x, 'Test262'); +assert.sameValue(imported.z, 42); diff --git a/test/language/module-code/dynamic-import/assign-expr-get-value-abrupt-throws.js b/test/language/module-code/dynamic-import/assign-expr-get-value-abrupt-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..acd0d96a7fb2b7dd0cdc5cd5403782de2afc13f3 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr-get-value-abrupt-throws.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Return Abrupt from the GetValue evaluation on the given AssignmentExpression +esid: sec-import-call-runtime-semantics-evaluation +info: | + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. +features: [dynamic-import] +---*/ + +const obj = { + get err() { + throw new Test262Error('catpure this on evaluation') + } +} + +assert.throws(Test262Error, function() { + import(obj.err); +}, 'Custom Error getting property value'); + +assert.throws(ReferenceError, function() { + import(refErr); +}, 'bad reference'); diff --git a/test/language/module-code/dynamic-import/catch/nested-arrow-import-catch-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-arrow-import-catch-eval-script-code-target.js new file mode 100644 index 0000000000000000000000000000000000000000..fa6011eea39264a1a87da7e6c2a55f98384661d0 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-arrow-import-catch-eval-script-code-target.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-arrow.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested arrow) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +let f = () => { + import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +}; + +f(); diff --git a/test/language/module-code/dynamic-import/catch/nested-arrow-import-catch-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-arrow-import-catch-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000000000000000000000000000000000..c5ed7e5264bd5d8383707039c6476c24785ed7a4 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-arrow-import-catch-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-arrow.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested arrow) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +let f = () => { + import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +}; + +f(); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-function-await-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-async-function-await-eval-script-code-target.js new file mode 100644 index 0000000000000000000000000000000000000000..94703c2121f8ecfdc113b93667fbe8a6e5080753 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-function-await-eval-script-code-target.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-async-function-await.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested in async function, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +async function f() { + await import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +} + +f(); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-function-await-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-async-function-await-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000000000000000000000000000000000..64e013be1139d6df57e9896a5f07f611a1fa0fa3 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-function-await-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-async-function-await.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested in async function, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +async function f() { + await import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +} + +f(); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-function-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-async-function-eval-script-code-target.js new file mode 100644 index 0000000000000000000000000000000000000000..c2b5b19daa3f8fa760d23135f83305f00b1ca412 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-function-eval-script-code-target.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-async-function.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested in async function) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +async function f() { + import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +} + +f(); + diff --git a/test/language/module-code/dynamic-import/catch/nested-async-function-return-await-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-async-function-return-await-eval-script-code-target.js new file mode 100644 index 0000000000000000000000000000000000000000..f63156e9e05b6accfb88393376c195f2bd88acae --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-function-return-await-eval-script-code-target.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-async-function-return-await.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested in async function, returns awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +async function f() { + return await import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +} + +f(); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-function-return-await-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-async-function-return-await-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000000000000000000000000000000000..f3ec1bfb54beed4166d0784fedaade780a3cd221 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-function-return-await-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-async-function-return-await.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested in async function, returns awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +async function f() { + return await import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +} + +f(); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-function-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-async-function-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000000000000000000000000000000000..70e3352eb050b56ff712439ce1b0e8edf761f0d5 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-function-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-async-function.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested in async function) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +async function f() { + import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +} + +f(); + diff --git a/test/language/module-code/dynamic-import/catch/nested-block-import-catch-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-block-import-catch-eval-script-code-target.js new file mode 100644 index 0000000000000000000000000000000000000000..aa11268fa662ce220c2f50b7f031d8848d3b4214 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-block-import-catch-eval-script-code-target.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-block.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested block) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +{ + import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +}; diff --git a/test/language/module-code/dynamic-import/catch/nested-block-import-catch-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-block-import-catch-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000000000000000000000000000000000..4a6398c76813798fa03082c2b66a32984e35d793 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-block-import-catch-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-block.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested block) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +{ + import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +}; diff --git a/test/language/module-code/dynamic-import/catch/nested-block-labeled-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-block-labeled-eval-script-code-target.js new file mode 100644 index 0000000000000000000000000000000000000000..7beb7101b1536c289dc840dad5e651e79afab60b --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-block-labeled-eval-script-code-target.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-block-labeled.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested block syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +label: { + import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +}; diff --git a/test/language/module-code/dynamic-import/catch/nested-block-labeled-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-block-labeled-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000000000000000000000000000000000..b6723a7059f8a8c68b3c9fc5acf945dea137d245 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-block-labeled-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-block-labeled.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested block syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +label: { + import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +}; diff --git a/test/language/module-code/dynamic-import/catch/nested-do-while-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-do-while-eval-script-code-target.js new file mode 100644 index 0000000000000000000000000000000000000000..4fd908472d72c05ecace144cd30530a27842b95d --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-do-while-eval-script-code-target.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-do-while.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested do while syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +do { + import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +} while (false); diff --git a/test/language/module-code/dynamic-import/catch/nested-do-while-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-do-while-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000000000000000000000000000000000..7525280a08ee899e95f1f96e10578b02ba2ad89f --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-do-while-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-do-while.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested do while syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +do { + import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +} while (false); diff --git a/test/language/module-code/dynamic-import/catch/nested-else-import-catch-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-else-import-catch-eval-script-code-target.js new file mode 100644 index 0000000000000000000000000000000000000000..001ff761a674d5bcf3212ffff202e00bba1cdb58 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-else-import-catch-eval-script-code-target.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-else.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested else) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +if (false) { + +} else { + import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +} diff --git a/test/language/module-code/dynamic-import/catch/nested-else-import-catch-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-else-import-catch-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000000000000000000000000000000000..6d8e0223ba858418d442591ac4bf57218a319a7d --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-else-import-catch-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-else.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested else) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +if (false) { + +} else { + import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +} diff --git a/test/language/module-code/dynamic-import/catch/nested-function-import-catch-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-function-import-catch-eval-script-code-target.js new file mode 100644 index 0000000000000000000000000000000000000000..f1f8d81cb3842dd0fc01357d5aece3a830881921 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-function-import-catch-eval-script-code-target.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-function.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested function) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +function f() { + import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +} +f(); diff --git a/test/language/module-code/dynamic-import/catch/nested-function-import-catch-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-function-import-catch-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000000000000000000000000000000000..1917a05566fd078cbabf3a55b926c6acaf78c2b3 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-function-import-catch-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-function.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested function) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +function f() { + import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +} +f(); diff --git a/test/language/module-code/dynamic-import/catch/nested-if-import-catch-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-if-import-catch-eval-script-code-target.js new file mode 100644 index 0000000000000000000000000000000000000000..86a7e0250f769fdc7351640f2890727f9972fd07 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-if-import-catch-eval-script-code-target.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-if.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested if) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +if (true) { + import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +} diff --git a/test/language/module-code/dynamic-import/catch/nested-if-import-catch-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-if-import-catch-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000000000000000000000000000000000..eca30e05e09ccc1916c437903865ce1bf062e584 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-if-import-catch-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-if.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested if) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +if (true) { + import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +} diff --git a/test/language/module-code/dynamic-import/catch/nested-while-import-catch-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-while-import-catch-eval-script-code-target.js new file mode 100644 index 0000000000000000000000000000000000000000..8676fd92c463a12c9de75dcc77f465dc5641d1c7 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-while-import-catch-eval-script-code-target.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-while.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested while) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +let x = 0; +while (!x) { + x++; + import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +}; diff --git a/test/language/module-code/dynamic-import/catch/nested-while-import-catch-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-while-import-catch-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000000000000000000000000000000000..ddf0987e06e2e97f472dc024a29e8a7cd56515b2 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-while-import-catch-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-while.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested while) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +let x = 0; +while (!x) { + x++; + import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +}; diff --git a/test/language/module-code/dynamic-import/catch/nested-with-import-catch-eval-rqstd-abrupt-typeerror.js b/test/language/module-code/dynamic-import/catch/nested-with-import-catch-eval-rqstd-abrupt-typeerror.js deleted file mode 100644 index cf8b175614cfc93e51a8dd345e565783c4105d3f..0000000000000000000000000000000000000000 --- a/test/language/module-code/dynamic-import/catch/nested-with-import-catch-eval-rqstd-abrupt-typeerror.js +++ /dev/null @@ -1,39 +0,0 @@ -// This file was procedurally generated from the following sources: -// - src/dynamic-import/eval-rqstd-abrupt-typeerror.case -// - src/dynamic-import/catch/nested-with.template -/*--- -description: Abrupt completion during module evaluation precludes further evaluation (nested with) -esid: sec-import-call-runtime-semantics-evaluation -features: [dynamic-import] -flags: [generated, async, noStrict] -info: | - ImportCall : - import( AssignmentExpression ) - - 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). - 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). - 3. Let argRef be the result of evaluating AssignmentExpression. - 4. Let specifier be ? GetValue(argRef). - 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). - 6. Let specifierString be ToString(specifier). - 7. IfAbruptRejectPromise(specifierString, promiseCapability). - 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). - 9. Return promiseCapability.[[Promise]]. - - - [...] - 6. For each String required that is an element of - module.[[RequestedModules]] do, - a. Let requiredModule be ? HostResolveImportedModule(module, required). - b. Perform ? requiredModule.ModuleEvaluation(). - ----*/ - -with ({}) { - import('./eval-rqstd-abrupt-err-type_FIXTURE.js').catch(error => { - - assert.sameValue(error.name, 'TypeError'); - - }).then($DONE, $DONE); -} - \ No newline at end of file diff --git a/test/language/module-code/dynamic-import/catch/nested-with-import-catch-eval-rqstd-abrupt-urierror.js b/test/language/module-code/dynamic-import/catch/nested-with-import-catch-eval-rqstd-abrupt-urierror.js deleted file mode 100644 index 7544674b0bdb3b36c661be904965c92f71ff31a9..0000000000000000000000000000000000000000 --- a/test/language/module-code/dynamic-import/catch/nested-with-import-catch-eval-rqstd-abrupt-urierror.js +++ /dev/null @@ -1,39 +0,0 @@ -// This file was procedurally generated from the following sources: -// - src/dynamic-import/eval-rqstd-abrupt-urierror.case -// - src/dynamic-import/catch/nested-with.template -/*--- -description: Abrupt completion during module evaluation precludes further evaluation (nested with) -esid: sec-import-call-runtime-semantics-evaluation -features: [dynamic-import] -flags: [generated, async, noStrict] -info: | - ImportCall : - import( AssignmentExpression ) - - 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). - 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). - 3. Let argRef be the result of evaluating AssignmentExpression. - 4. Let specifier be ? GetValue(argRef). - 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). - 6. Let specifierString be ToString(specifier). - 7. IfAbruptRejectPromise(specifierString, promiseCapability). - 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). - 9. Return promiseCapability.[[Promise]]. - - - [...] - 6. For each String required that is an element of - module.[[RequestedModules]] do, - a. Let requiredModule be ? HostResolveImportedModule(module, required). - b. Perform ? requiredModule.ModuleEvaluation(). - ----*/ - -with ({}) { - import('./eval-rqstd-abrupt-err-uri_FIXTURE.js').catch(error => { - - assert.sameValue(error.name, 'URIError'); - - }).then($DONE, $DONE); -} - \ No newline at end of file diff --git a/test/language/module-code/dynamic-import/catch/nested-with-import-catch-file-does-not-exist.js b/test/language/module-code/dynamic-import/catch/nested-with-import-catch-file-does-not-exist.js deleted file mode 100644 index 082c42f568af3ce9417f5574b63a90630811057e..0000000000000000000000000000000000000000 --- a/test/language/module-code/dynamic-import/catch/nested-with-import-catch-file-does-not-exist.js +++ /dev/null @@ -1,36 +0,0 @@ -// This file was procedurally generated from the following sources: -// - src/dynamic-import/file-does-not-exist.case -// - src/dynamic-import/catch/nested-with.template -/*--- -description: Non existent file can't resolve to a Script or Module Record (nested with) -esid: sec-import-call-runtime-semantics-evaluation -features: [dynamic-import] -flags: [generated, async, noStrict] -info: | - ImportCall : - import( AssignmentExpression ) - - 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). - 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). - 3. Let argRef be the result of evaluating AssignmentExpression. - 4. Let specifier be ? GetValue(argRef). - 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). - 6. Let specifierString be ToString(specifier). - 7. IfAbruptRejectPromise(specifierString, promiseCapability). - 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). - 9. Return promiseCapability.[[Promise]]. - - - If a Module Record corresponding to the pair referencingModulereferencingScriptOrModule, - specifier does not exist or cannot be created, an exception must be thrown. - ----*/ - -with ({}) { - import('./THIS_FILE_DOES_NOT_EXIST.js').catch(error => { - - assert.notSameValue(typeof error, 'undefined'); - - }).then($DONE, $DONE); -} - \ No newline at end of file diff --git a/test/language/module-code/dynamic-import/catch/nested-with-import-catch-instn-iee-err-ambiguous-import.js b/test/language/module-code/dynamic-import/catch/nested-with-import-catch-instn-iee-err-ambiguous-import.js deleted file mode 100644 index 028e8d510457ea0b80e04643c81514f103a80e95..0000000000000000000000000000000000000000 --- a/test/language/module-code/dynamic-import/catch/nested-with-import-catch-instn-iee-err-ambiguous-import.js +++ /dev/null @@ -1,60 +0,0 @@ -// This file was procedurally generated from the following sources: -// - src/dynamic-import/instn-iee-err-ambiguous-import.case -// - src/dynamic-import/catch/nested-with.template -/*--- -description: IndirectExportEntries validation - ambiguous imported bindings (nested with) -esid: sec-import-call-runtime-semantics-evaluation -features: [dynamic-import] -flags: [generated, async, noStrict] -info: | - ImportCall : - import( AssignmentExpression ) - - 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). - 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). - 3. Let argRef be the result of evaluating AssignmentExpression. - 4. Let specifier be ? GetValue(argRef). - 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). - 6. Let specifierString be ToString(specifier). - 7. IfAbruptRejectPromise(specifierString, promiseCapability). - 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). - 9. Return promiseCapability.[[Promise]]. - - - [...] - 9. For each ExportEntry Record e in module.[[IndirectExportEntries]], do - a. Let resolution be ? module.ResolveExport(e.[[ExportName]], « », « »). - b. If resolution is null or resolution is "ambiguous", throw a - SyntaxError exception. - [...] - - 15.2.1.16.3 ResolveExport - - [...] - 9. Let starResolution be null. - 10. For each ExportEntry Record e in module.[[StarExportEntries]], do - a. Let importedModule be ? HostResolveImportedModule(module, - e.[[ModuleRequest]]). - b. Let resolution be ? importedModule.ResolveExport(exportName, - resolveSet, exportStarSet). - c. If resolution is "ambiguous", return "ambiguous". - d. If resolution is not null, then - i. If starResolution is null, let starResolution be resolution. - ii. Else, - 1. Assert: there is more than one * import that includes the - requested name. - 2. If resolution.[[Module]] and starResolution.[[Module]] are - not the same Module Record or - SameValue(resolution.[[BindingName]], - starResolution.[[BindingName]]) is false, return "ambiguous". - ----*/ - -with ({}) { - import('./instn-iee-err-ambiguous-export_FIXTURE.js').catch(error => { - - assert.sameValue(error.name, 'SyntaxError'); - - }).then($DONE, $DONE); -} - \ No newline at end of file diff --git a/test/language/module-code/dynamic-import/catch/nested-with-import-catch-instn-iee-err-circular.js b/test/language/module-code/dynamic-import/catch/nested-with-import-catch-instn-iee-err-circular.js deleted file mode 100644 index 07dd99c5019d9b3192e3ded3d0cc4d92ffbe8625..0000000000000000000000000000000000000000 --- a/test/language/module-code/dynamic-import/catch/nested-with-import-catch-instn-iee-err-circular.js +++ /dev/null @@ -1,49 +0,0 @@ -// This file was procedurally generated from the following sources: -// - src/dynamic-import/instn-iee-err-circular.case -// - src/dynamic-import/catch/nested-with.template -/*--- -description: IndirectExportEntries validation - circular imported bindings (nested with) -esid: sec-import-call-runtime-semantics-evaluation -features: [dynamic-import] -flags: [generated, async, noStrict] -info: | - ImportCall : - import( AssignmentExpression ) - - 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). - 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). - 3. Let argRef be the result of evaluating AssignmentExpression. - 4. Let specifier be ? GetValue(argRef). - 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). - 6. Let specifierString be ToString(specifier). - 7. IfAbruptRejectPromise(specifierString, promiseCapability). - 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). - 9. Return promiseCapability.[[Promise]]. - - - [...] - 9. For each ExportEntry Record e in module.[[IndirectExportEntries]], do - a. Let resolution be ? module.ResolveExport(e.[[ExportName]], « », « »). - b. If resolution is null or resolution is "ambiguous", throw a - SyntaxError exception. - [...] - - 15.2.1.16.3 ResolveExport - - [...] - 2. For each Record {[[Module]], [[ExportName]]} r in resolveSet, do: - a. If module and r.[[Module]] are the same Module Record and - SameValue(exportName, r.[[ExportName]]) is true, then - i. Assert: this is a circular import request. - ii. Return null. - ----*/ - -with ({}) { - import('./instn-iee-err-circular-1_FIXTURE.js').catch(error => { - - assert.sameValue(error.name, 'SyntaxError'); - - }).then($DONE, $DONE); -} - \ No newline at end of file diff --git a/test/language/module-code/dynamic-import/catch/script-code_FIXTURE.js b/test/language/module-code/dynamic-import/catch/script-code_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..131ffcee7121377266937fee42dea29fa426d58b --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/script-code_FIXTURE.js @@ -0,0 +1,7 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +// This is still valid in script code and strict and non strict modes +// This is valid as module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} diff --git a/test/language/module-code/dynamic-import/catch/top-level-import-catch-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/top-level-import-catch-eval-script-code-target.js new file mode 100644 index 0000000000000000000000000000000000000000..daae4c13fe9c09f804dbec4e601b6e96c36ebf7d --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/top-level-import-catch-eval-script-code-target.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/top-level.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (top level) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/top-level-import-catch-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/top-level-import-catch-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000000000000000000000000000000000..02ecae37f56e321939c45ba71605d056a208e7ef --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/top-level-import-catch-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/top-level.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (top level) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/dynamic-import-module_FIXTURE.js b/test/language/module-code/dynamic-import/dynamic-import-module_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..ef3f4207cd745179e169cb1aa8776c167dfe7d21 --- /dev/null +++ b/test/language/module-code/dynamic-import/dynamic-import-module_FIXTURE.js @@ -0,0 +1,4 @@ +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export var x = 1; diff --git a/test/language/module-code/dynamic-import/ns/await-ns-Symbol-toStringTag.js b/test/language/module-code/dynamic-import/ns/await-ns-Symbol-toStringTag.js new file mode 100644 index 0000000000000000000000000000000000000000..585a039ab067a90f0c2697fda129f94946720f00 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-Symbol-toStringTag.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-Symbol-toStringTag.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Module namespace objects have a Symbol.toStringTag (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol.toStringTag, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: false }. + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(ns[Symbol.toStringTag], 'Module'); + + // propertyHelper.js is not appropriate for this test because it assumes that + // the object exposes the ordinary object's implementation of [[Get]], [[Set]], +// [[Delete]], and [[OwnPropertyKeys]], which the module namespace exotic +// object does not. +var desc = Object.getOwnPropertyDescriptor(ns, Symbol.toStringTag); + +assert.sameValue(desc.enumerable, false, 'reports as non-enumerable'); +assert.sameValue(desc.writable, false, 'reports as non-writable'); +assert.sameValue(desc.configurable, false, 'reports as non-configurable'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-define-own-property.js b/test/language/module-code/dynamic-import/ns/await-ns-define-own-property.js new file mode 100644 index 0000000000000000000000000000000000000000..62f67ee2ee04ba11cfd92e4c323c902958f4e555 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-define-own-property.js @@ -0,0 +1,177 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-define-own-property.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[DefineOwnProperty]] internal method returns `true` if no change is requested, and `false` otherwise. (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol.iterator, Reflect, Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ +var sym = Symbol('test262'); + +const exported = ['local1', 'renamed', 'indirect']; + + +async function fn() { + const ns = await import('./define-own-property_FIXTURE.js'); + + // Non-existant properties. + + for (const key of ['local2', 0, sym, Symbol.iterator]) { + assert.sameValue( + Reflect.defineProperty(ns, key, {}), + false, + 'Reflect.defineProperty: ' + key.toString() + ); + assert.throws(TypeError, function() { + Object.defineProperty(ns, key, {}); + }, 'Object.defineProperty: ' + key.toString()); + } + + // Own properties. No change requested. + + for (const key of ([...exported, Symbol.toStringTag])) { + assert.sameValue( + Reflect.defineProperty(ns, key, {}), + true, + `No change requested, Reflect.defineProperty: ${key.toString()}` + ); + assert.sameValue( + Object.defineProperty(ns, key, {}), + ns, + `No change requested, Object.defineProperty: ${key.toString()}` + ); + + } + + assert.sameValue( + Reflect.defineProperty(ns, 'indirect', + {writable: true, enumerable: true, configurable: false}), + true, + 'Reflect.defineProperty: indirect' + ); + assert.sameValue( + Object.defineProperty(ns, 'indirect', + {writable: true, enumerable: true, configurable: false}), + ns, + 'Object.defineProperty: indirect' + ); + + assert.sameValue( + Reflect.defineProperty(ns, Symbol.toStringTag, + {value: "Module", writable: false, enumerable: false, + configurable: false}), + true, + 'Reflect.defineProperty: Symbol.toStringTag' + ); + assert.sameValue( + Object.defineProperty(ns, Symbol.toStringTag, + {value: "Module", writable: false, enumerable: false, + configurable: false}), + ns, + 'Object.defineProperty: Symbol.toStringTag' + ); + + + // Own properties. Change requested. + + for (const key of ([...exported, Symbol.toStringTag])) { + assert.sameValue( + Reflect.defineProperty(ns, key, {value: 123}), + false, + `Change requested, Reflect.defineProperty: ${key.toString()}` + ); + assert.throws(TypeError, function() { + Object.defineProperty(ns, key, {value: 123}); + }, `Change requested, Object.defineProperty: ${key.toString()}`); + } + + assert.sameValue( + Reflect.defineProperty(ns, 'indirect', + {writable: true, enumerable: true, configurable: true}), + false, + 'Reflect.defineProperty: indirect' + ); + assert.throws(TypeError, function() { + Object.defineProperty(ns, 'indirect', + {writable: true, enumerable: true, configurable: true}); + }, 'Object.defineProperty: indirect'); + + assert.sameValue( + Reflect.defineProperty(ns, Symbol.toStringTag, + {value: "module", writable: false, enumerable: false, + configurable: false}), + false, + 'Reflect.defineProperty: Symbol.toStringTag' + ); + assert.throws(TypeError, function() { + Object.defineProperty(ns, Symbol.toStringTag, + {value: "module", writable: false, enumerable: false, + configurable: false}); + }, 'Object.defineProperty: Symbol.toStringTag'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-delete-exported-init-no-strict.js b/test/language/module-code/dynamic-import/ns/await-ns-delete-exported-init-no-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..3daa25f30e875cfa4e65df3df8d6fe2106f7d0ee --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-delete-exported-init-no-strict.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-delete-exported-init-no-strict.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[Delete]] behavior for a key that describes an initialized exported binding on non strict mode (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, noStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryDelete(O, P). + 3. Let exports be O.[[Exports]]. + 4. If P is an element of exports, return false. + 5. Return true. + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(delete ns.default, false, 'delete: default'); + assert.sameValue( + Reflect.deleteProperty(ns, 'default'), false, 'Reflect.deleteProperty: default' + ); + assert.sameValue(ns.default, 42, 'binding unmodified: default'); + + assert.sameValue(delete ns.local1, false, 'delete: local1'); + assert.sameValue( + Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1' + ); + assert.sameValue(ns.local1, 'Test262', 'binding unmodified: local1'); + + assert.sameValue(delete ns.renamed, false, 'delete: renamed'); + assert.sameValue( + Reflect.deleteProperty(ns, 'renamed'), false, 'Reflect.deleteProperty: renamed' + ); + assert.sameValue(ns.renamed, 'TC39', 'binding unmodified: renamed'); + + assert.sameValue(delete ns.indirect, false, 'delete: indirect'); + assert.sameValue( + Reflect.deleteProperty(ns, 'indirect'), + false, + 'Reflect.deleteProperty: indirect' + ); + assert.sameValue(ns.indirect, 'Test262', 'binding unmodified: indirect'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-delete-exported-init-strict.js b/test/language/module-code/dynamic-import/ns/await-ns-delete-exported-init-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..9a93989c80eb9527955671150288627df7dcda43 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-delete-exported-init-strict.js @@ -0,0 +1,120 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-delete-exported-init-strict.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[Delete]] behavior for a key that describes an initialized exported binding on strict mode (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, onlyStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryDelete(O, P). + 3. Let exports be O.[[Exports]]. + 4. If P is an element of exports, return false. + 5. Return true. + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.throws(TypeError, function() { + delete ns.default; + }, 'delete: default'); + assert.sameValue( + Reflect.deleteProperty(ns, 'default'), false, 'Reflect.deleteProperty: default' + ); + assert.sameValue(ns.default, 42, 'binding unmodified: default'); + + assert.throws(TypeError, function() { + delete ns.local1; + }, 'delete: local1'); + assert.sameValue( + Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1' + ); + assert.sameValue(ns.local1, 'Test262', 'binding unmodified: local1'); + + assert.throws(TypeError, function() { + delete ns.renamed; + }, 'delete: renamed'); + assert.sameValue( + Reflect.deleteProperty(ns, 'renamed'), false, 'Reflect.deleteProperty: renamed' + ); + assert.sameValue(ns.renamed, 'TC39', 'binding unmodified: renamed'); + + assert.throws(TypeError, function() { + delete ns.indirect; + }, 'delete: indirect'); + assert.sameValue( + Reflect.deleteProperty(ns, 'indirect'), + false, + 'Reflect.deleteProperty: indirect' + ); + assert.sameValue(ns.indirect, 'Test262', 'binding unmodified: indirect'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-delete-non-exported-no-strict.js b/test/language/module-code/dynamic-import/ns/await-ns-delete-non-exported-no-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..c695bbfff2f8b0f3bfe57c03620cfcc58ea39cc1 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-delete-non-exported-no-strict.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-delete-non-exported-no-strict.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[Delete]] behavior for a key that does not describe an exported binding (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, noStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryDelete(O, P). + 3. Let exports be O.[[Exports]]. + 4. If P is an element of exports, return false. + 5. Return true. + +---*/ + +async function fn() { + const ns = await import('./empty_FIXTURE.js'); + + assert(delete ns.undef, 'delete: undef'); + assert(Reflect.deleteProperty(ns, 'undef'), 'Reflect.deleteProperty: undef'); + + assert(delete ns.default, 'delete: default'); + assert( + Reflect.deleteProperty(ns, 'default'), 'Reflect.deleteProperty: default' + ); + + assert.sameValue(delete ns[Symbol.toStringTag], false, 'delete: Symbol.toStringTag'); + assert.sameValue( + Reflect.deleteProperty(ns, Symbol.toStringTag), false, + 'Reflect.deleteProperty: Symbol.toStringTag' + ); + + var sym = Symbol('test262'); + assert(delete ns[sym], 'delete: symbol'); + assert(Reflect.deleteProperty(ns, sym), 'Reflect.deleteProperty: symbol'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-delete-non-exported-strict.js b/test/language/module-code/dynamic-import/ns/await-ns-delete-non-exported-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..6d46175991c491bfca3d1c057a34d69a150ddf98 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-delete-non-exported-strict.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-delete-non-exported-strict.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[Delete]] behavior for a key that does not describe an exported binding (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, onlyStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryDelete(O, P). + 3. Let exports be O.[[Exports]]. + 4. If P is an element of exports, return false. + 5. Return true. + +---*/ + +async function fn() { + const ns = await import('./empty_FIXTURE.js'); + + assert(delete ns.undef, 'delete: undef'); + assert(Reflect.deleteProperty(ns, 'undef'), 'Reflect.deleteProperty: undef'); + + assert(delete ns.default, 'delete: default'); + assert( + Reflect.deleteProperty(ns, 'default'), 'Reflect.deleteProperty: default' + ); + + assert.sameValue( + Reflect.deleteProperty(ns, Symbol.toStringTag), false, + 'Reflect.deleteProperty: Symbol.toStringTag' + ); + assert.throws(TypeError, function() { delete ns[Symbol.toStringTag]; }, 'delete: Symbol.toStringTag'); + + var sym = Symbol('test262'); + assert(delete ns[sym], 'delete: symbol'); + assert(Reflect.deleteProperty(ns, sym), 'Reflect.deleteProperty: symbol'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-extensible.js b/test/language/module-code/dynamic-import/ns/await-ns-extensible.js new file mode 100644 index 0000000000000000000000000000000000000000..e35aa7418fa8a40d07a15b05154e1cf41b7b8071 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-extensible.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-extensible.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Module namespace objects are not extensible. (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(Object.isExtensible(ns), false); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-get-nested-namespace-dflt-direct.js b/test/language/module-code/dynamic-import/ns/await-ns-get-nested-namespace-dflt-direct.js new file mode 100644 index 0000000000000000000000000000000000000000..52656a88cec4247928a1fe7a5bdbcec18de975bc --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-get-nested-namespace-dflt-direct.js @@ -0,0 +1,126 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-nested-namespace-dflt-direct.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Direct Default exports are included in an imported module namespace object when a namespace object is created. (value from await resolving) +esid: sec-finishdynamicimport +features: [export-star-as-namespace-from-module, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 6. Let binding be ! m.ResolveExport(P, « »). + 7. Assert: binding is a ResolvedBinding Record. + 8. Let targetModule be binding.[[Module]]. + 9. Assert: targetModule is not undefined. + 10. If binding.[[BindingName]] is "*namespace*", then + 11. Return ? GetModuleNamespace(targetModule). + + Runtime Semantics: GetModuleNamespace + [...] + 3. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, + i. Let resolution be ? module.ResolveExport(name, « », « »). + ii. If resolution is null, throw a SyntaxError exception. + iii. If resolution is not "ambiguous", append name to + unambiguousNames. + d. Let namespace be ModuleNamespaceCreate(module, unambiguousNames). + [...] + +---*/ + +async function fn() { + const ns = await import('./get-nested-namespace-dflt-skip-prod_FIXTURE.js'); + + var desc = Object.getOwnPropertyDescriptor(ns, 'productionNS2'); + + assert.sameValue(desc.enumerable, true, 'ns.productionNS2: is enumerable'); + assert.sameValue(desc.writable, true, 'ns.productionNS2: is writable'); + assert.sameValue(desc.configurable, false, 'ns.productionNS2: is non-configurable'); + + var keys = Object.keys(ns.productionNS2); + + assert.sameValue(keys.length, 2); + assert.sameValue(keys[0], 'default'); + assert.sameValue(keys[1], 'productionOther'); + + desc = Object.getOwnPropertyDescriptor(ns.productionNS2, 'productionOther'); + + assert.sameValue(desc.value, null, 'ns.productionNS2.productionOther: value is null'); + assert.sameValue(desc.enumerable, true, 'ns.productionNS2.productionOther: is enumerable'); + assert.sameValue(desc.writable, true, 'ns.productionNS2.productionOther: is writable'); + assert.sameValue(desc.configurable, false, 'ns.productionNS2.productionOther: is non-configurable'); + + desc = Object.getOwnPropertyDescriptor(ns.productionNS2, 'default'); + + assert.sameValue(desc.value, 42, 'ns.productionNS2.default value is 42'); + assert.sameValue(desc.enumerable, true, 'ns.productionNS2.default is enumerable'); + assert.sameValue(desc.writable, true, 'ns.productionNS2.default is writable'); + assert.sameValue(desc.configurable, false, 'ns.productionNS2.default is non-configurable'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-get-nested-namespace-dflt-indirect.js b/test/language/module-code/dynamic-import/ns/await-ns-get-nested-namespace-dflt-indirect.js new file mode 100644 index 0000000000000000000000000000000000000000..01a995135e6c0678180101271314321955a2eac3 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-get-nested-namespace-dflt-indirect.js @@ -0,0 +1,126 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-nested-namespace-dflt-indirect.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Inirect Default exports are included in an imported module namespace object when a namespace object is created. (value from await resolving) +esid: sec-finishdynamicimport +features: [export-star-as-namespace-from-module, dynamic-import] +flags: [generated, module, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 6. Let binding be ! m.ResolveExport(P, « »). + 7. Assert: binding is a ResolvedBinding Record. + 8. Let targetModule be binding.[[Module]]. + 9. Assert: targetModule is not undefined. + 10. If binding.[[BindingName]] is "*namespace*", then + 11. Return ? GetModuleNamespace(targetModule). + + Runtime Semantics: GetModuleNamespace + [...] + 3. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, + i. Let resolution be ? module.ResolveExport(name, « », « »). + ii. If resolution is null, throw a SyntaxError exception. + iii. If resolution is not "ambiguous", append name to + unambiguousNames. + d. Let namespace be ModuleNamespaceCreate(module, unambiguousNames). + [...] + +---*/ + +async function fn() { + const ns = await import('./get-nested-namespace-dflt-skip-named_FIXTURE.js'); + + var desc = Object.getOwnPropertyDescriptor(ns, 'namedNS2'); + + assert.sameValue(desc.enumerable, true, 'ns.namedNS2: is enumerable'); + assert.sameValue(desc.writable, true, 'ns.namedNS2: is writable'); + assert.sameValue(desc.configurable, false, 'ns.namedNS2: is non-configurable'); + + var keys = Object.keys(ns.namedNS2); + + assert.sameValue(keys.length, 2); + assert.sameValue(keys[0], 'default'); + assert.sameValue(keys[1], 'namedOther'); + + desc = Object.getOwnPropertyDescriptor(ns.namedNS2, 'namedOther'); + + assert.sameValue(desc.value, null, 'ns.namedNS2.namedOther value is null'); + assert.sameValue(desc.enumerable, true, 'ns.namedNS2.namedOther: is enumerable'); + assert.sameValue(desc.writable, true, 'ns.namedNS2.namedOther: is writable'); + assert.sameValue(desc.configurable, false, 'ns.namedNS2.namedOther: is non-configurable'); + + desc = Object.getOwnPropertyDescriptor(ns.namedNS2, 'default'); + + assert.sameValue(desc.value, 42, 'ns.namedNS2.default value is 42'); + assert.sameValue(desc.enumerable, true, 'ns.namedNS2.default is enumerable'); + assert.sameValue(desc.writable, true, 'ns.namedNS2.default is writable'); + assert.sameValue(desc.configurable, false, 'ns.namedNS2.default is non-configurable'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-get-nested-namespace-props-nrml.js b/test/language/module-code/dynamic-import/ns/await-ns-get-nested-namespace-props-nrml.js new file mode 100644 index 0000000000000000000000000000000000000000..c19ba12a3c2809ffef8c927b2d3e46eeb2d6e74d --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-get-nested-namespace-props-nrml.js @@ -0,0 +1,123 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-nested-namespace-props-nrml.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Module namespace object reports properties for all ExportEntries of all dependencies. (value from await resolving) +esid: sec-finishdynamicimport +features: [export-star-as-namespace-from-module, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 12. For each ImportEntry Record in in module.[[ImportEntries]], do + a. Let importedModule be ? HostResolveImportedModule(module, + in.[[ModuleRequest]]). + b. If in.[[ImportName]] is "*", then + i. Let namespace be ? GetModuleNamespace(importedModule). + [...] + + Runtime Semantics: GetModuleNamespace + 3. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, + i. Let resolution be ? module.ResolveExport(name, « », « »). + ii. If resolution is null, throw a SyntaxError exception. + iii. If resolution is not "ambiguous", append name to + unambiguousNames. + d. Let namespace be ModuleNamespaceCreate(module, unambiguousNames). + +---*/ +function hasOwnProperty(obj, property) { + return Object.prototype.hasOwnProperty.call(obj, property); +} + + +async function fn() { + const ns = await import('./get-nested-namespace-props-nrml-1_FIXTURE.js'); + + // Export entries defined by a re-exported as exportns module + assert(hasOwnProperty(ns.exportns, 'starAsVarDecl'), 'starssVarDecl'); + assert(hasOwnProperty(ns.exportns, 'starAsLetDecl'), 'starSsLetDecl'); + assert(hasOwnProperty(ns.exportns, 'starAsConstDecl'), 'starSsConstDecl'); + assert(hasOwnProperty(ns.exportns, 'starAsFuncDecl'), 'starAsFuncDecl'); + assert(hasOwnProperty(ns.exportns, 'starAsGenDecl'), 'starAsGenDecl'); + assert(hasOwnProperty(ns.exportns, 'starAsClassDecl'), 'starAsClassDecl'); + assert(hasOwnProperty(ns.exportns, 'starAsBindingId'), 'starAsBindingId'); + assert(hasOwnProperty(ns.exportns, 'starIdName'), 'starIdName'); + assert(hasOwnProperty(ns.exportns, 'starAsIndirectIdName'), 'starAsIndirectIdName'); + assert(hasOwnProperty(ns.exportns, 'starAsIndirectIdName2'), 'starAsIndirectIdName2'); + assert(hasOwnProperty(ns.exportns, 'namespaceBinding'), 'namespaceBinding'); + + // Bindings that were not exported from any module + assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedVar'), false, 'nonExportedVar'); + assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedLet'), false, 'nonExportedLet'); + assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedConst'), false, 'nonExportedConst'); + assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedFunc'), false, 'nonExportedFunc'); + assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedGen'), false, 'nonExportedGen'); + assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedClass'), false, 'nonExportedClass'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-get-own-property-str-found-init.js b/test/language/module-code/dynamic-import/ns/await-ns-get-own-property-str-found-init.js new file mode 100644 index 0000000000000000000000000000000000000000..0577d03135b1ca9b27668cf3f489c751af796e59 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-get-own-property-str-found-init.js @@ -0,0 +1,124 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-own-property-str-found-init.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[GetOwnProperty]] internal method with a string argument describing an initialized binding (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. If Type(P) is Symbol, return OrdinaryGetOwnProperty(O, P). + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is not an element of exports, return undefined. + 4. Let value be ? O.[[Get]](P, O). + 5. Return PropertyDescriptor{[[Value]]: value, [[Writable]]: true, + [[Enumerable]]: true, [[Configurable]]: false }. + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + var desc; + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'local1'), true + ); + desc = Object.getOwnPropertyDescriptor(ns, 'local1'); + assert.sameValue(desc.value, 'Test262'); + assert.sameValue(desc.enumerable, true, 'local1 enumerable'); + assert.sameValue(desc.writable, true, 'local1 writable'); + assert.sameValue(desc.configurable, false, 'local1 configurable'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'renamed'), true + ); + desc = Object.getOwnPropertyDescriptor(ns, 'renamed'); + assert.sameValue(desc.value, 'TC39'); + assert.sameValue(desc.enumerable, true, 'renamed enumerable'); + assert.sameValue(desc.writable, true, 'renamed writable'); + assert.sameValue(desc.configurable, false, 'renamed configurable'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'indirect'), true + ); + desc = Object.getOwnPropertyDescriptor(ns, 'indirect'); + assert.sameValue(desc.value, 'Test262'); + assert.sameValue(desc.enumerable, true, 'indirect enumerable'); + assert.sameValue(desc.writable, true, 'indirect writable'); + assert.sameValue(desc.configurable, false, 'indirect configurable'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'default'), true + ); + desc = Object.getOwnPropertyDescriptor(ns, 'default'); + assert.sameValue(desc.value, 42); + assert.sameValue(desc.enumerable, true, 'default enumerable'); + assert.sameValue(desc.writable, true, 'default writable'); + assert.sameValue(desc.configurable, false, 'default configurable'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-get-own-property-str-not-found.js b/test/language/module-code/dynamic-import/ns/await-ns-get-own-property-str-not-found.js new file mode 100644 index 0000000000000000000000000000000000000000..abf689fcfe32942cb3575d769912c3dd4efaeac5 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-get-own-property-str-not-found.js @@ -0,0 +1,117 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-own-property-str-not-found.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[GetOwnProperty]] internal method with a string argument describing a binding that cannot be found (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. If Type(P) is Symbol, return OrdinaryGetOwnProperty(O, P). + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is not an element of exports, return undefined. + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + var desc; + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'local2'), + false, + 'hasOwnProperty: local2' + ); + desc = Object.getOwnPropertyDescriptor(ns, 'local2'); + assert.sameValue(desc, undefined, 'property descriptor for "local2"'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'toStringTag'), + false, + 'hasOwnProperty: toStringTag' + ); + desc = Object.getOwnPropertyDescriptor(ns, 'toStringTag'); + assert.sameValue(desc, undefined, 'property descriptor for "toStringTag"'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'iterator'), + false, + 'hasOwnProperty: iterator' + ); + desc = Object.getOwnPropertyDescriptor(ns, 'iterator'); + assert.sameValue(desc, undefined, 'property descriptor for "iterator"'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, '__proto__'), + false, + 'hasOwnProperty: __proto__' + ); + desc = Object.getOwnPropertyDescriptor(ns, '__proto__'); + assert.sameValue(desc, undefined, 'property descriptor for "__proto__"'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-get-own-property-sym.js b/test/language/module-code/dynamic-import/ns/await-ns-get-own-property-sym.js new file mode 100644 index 0000000000000000000000000000000000000000..318788e28b20df0d3f69e4037c157648181cabdc --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-get-own-property-sym.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-own-property-sym.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[GetOwnProperty]] internal method with a Symbol argument (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ +var notFound = Symbol('test262'); + + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + var desc; + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, Symbol.toStringTag), true + ); + desc = Object.getOwnPropertyDescriptor(ns, Symbol.toStringTag); + assert.sameValue(desc.value, ns[Symbol.toStringTag]); + assert.sameValue(desc.enumerable, false, 'Symbol.toStringTag enumerable'); + assert.sameValue(desc.writable, false, 'Symbol.toStringTag writable'); + assert.sameValue(desc.configurable, false, 'Symbol.toStringTag configurable'); + + assert.sameValue(Object.prototype.hasOwnProperty.call(ns, notFound), false); + desc = Object.getOwnPropertyDescriptor(ns, notFound); + assert.sameValue(desc, undefined); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-get-str-found.js b/test/language/module-code/dynamic-import/ns/await-ns-get-str-found.js new file mode 100644 index 0000000000000000000000000000000000000000..0a971a6944428b76d2e0c16af5c11d117b978164 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-get-str-found.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-str-found.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[Get]] internal method with a string argument for exported initialized bindings. (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 12. Let targetEnvRec be targetEnv's EnvironmentRecord. + 13. Return ? targetEnvRec.GetBindingValue(binding.[[BindingName]], true). + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(ns.local1, 'Test262'); + assert.sameValue(ns.renamed, 'TC39'); + assert.sameValue(ns.indirect, 'Test262'); + assert.sameValue(ns.default, 42); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-get-str-not-found.js b/test/language/module-code/dynamic-import/ns/await-ns-get-str-not-found.js new file mode 100644 index 0000000000000000000000000000000000000000..4c15994aee17ad405343ab362d73349eeaff975c --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-get-str-not-found.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-str-not-found.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[Get]] internal method with a string argument for non-exported bindings (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 3. Let exports be the value of O's [[Exports]] internal slot. + 4. If P is not an element of exports, return undefined. + +---*/ +var local2; // not used + + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(ns.local2, undefined, 'key: local2'); + assert.sameValue(ns.toStringTag, undefined, 'key: toStringTag'); + assert.sameValue(ns.iterator, undefined, 'key: iterator'); + assert.sameValue(ns.__proto__, undefined, 'key: __proto__'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-get-sym-found.js b/test/language/module-code/dynamic-import/ns/await-ns-get-sym-found.js new file mode 100644 index 0000000000000000000000000000000000000000..da8c6c2797eda12a73835090dd4d776148312ced --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-get-sym-found.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-sym-found.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[Get]] internal method with a symbol argument that can be found (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol.toStringTag, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryGet(O, P, Receiver). + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(typeof ns[Symbol.toStringTag], 'string'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-get-sym-not-found.js b/test/language/module-code/dynamic-import/ns/await-ns-get-sym-not-found.js new file mode 100644 index 0000000000000000000000000000000000000000..3366101da4e9847bbdf4fcd5146e6a1c21938820 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-get-sym-not-found.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-sym-not-found.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[Get]] internal method with a symbol argument that cannot be found (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryGet(O, P, Receiver). + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(ns[Symbol('test262')], undefined, 'Symbol: test262'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-has-property-str-found-init.js b/test/language/module-code/dynamic-import/ns/await-ns-has-property-str-found-init.js new file mode 100644 index 0000000000000000000000000000000000000000..7e12f8b083e56661b1ff4971977afa1b57dfbbf7 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-has-property-str-found-init.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-has-property-str-found-init.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[HasProperty]] internal method with a string argument for exported initialized bindings. (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is an element of exports, return true. + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert('local1' in ns, 'in: local1'); + assert(Reflect.has(ns, 'local1'), 'Reflect.has: local1'); + + assert('renamed' in ns, 'in: renamed'); + assert(Reflect.has(ns, 'renamed'), 'Reflect.has: renamed'); + + assert('indirect' in ns, 'in: indirect'); + assert(Reflect.has(ns, 'indirect'), 'Reflect.has: indirect'); + + assert('default' in ns, 'in: default'); + assert(Reflect.has(ns, 'default'), 'Reflect.has: default'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-has-property-str-not-found.js b/test/language/module-code/dynamic-import/ns/await-ns-has-property-str-not-found.js new file mode 100644 index 0000000000000000000000000000000000000000..7d241a47a013902be6625277935a71193409f1a7 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-has-property-str-not-found.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-has-property-str-not-found.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[HasProperty]] internal method with a string argument for non-exported bindings (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is an element of exports, return true. + 4. Return false. + +---*/ +var local2; // not used + + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue('local2' in ns, false, 'in: local2'); + assert.sameValue(Reflect.has(ns, 'local2'), false, 'Reflect.has: local2'); + + assert.sameValue('toStringTag' in ns, false, 'in: toStringTag'); + assert.sameValue( + Reflect.has(ns, 'toStringTag'), false, 'Reflect.has: toStringTag' + ); + + assert.sameValue('iterator' in ns, false, 'in: iterator'); + assert.sameValue(Reflect.has(ns, 'iterator'), false, 'Reflect.has: iterator'); + + assert.sameValue('__proto__' in ns, false, 'in: __proto__'); + assert.sameValue( + Reflect.has(ns, '__proto__'), false, 'Reflect.has: __proto__' + ); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-has-property-sym-found.js b/test/language/module-code/dynamic-import/ns/await-ns-has-property-sym-found.js new file mode 100644 index 0000000000000000000000000000000000000000..1e68c121ca331c1f54fa32d6cec2ceb0abb65d13 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-has-property-sym-found.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-has-property-sym-found.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[HasProperty]] internal method with a symbol argument that can be found (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol.toStringTag, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. If Type(P) is Symbol, return OrdinaryHasProperty(O, P). + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert(Symbol.toStringTag in ns, 'in: Symbol.toStringTag'); + assert(Reflect.has(ns, Symbol.toStringTag), 'Reflect.has: Symbol.toStringTag'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-has-property-sym-not-found.js b/test/language/module-code/dynamic-import/ns/await-ns-has-property-sym-not-found.js new file mode 100644 index 0000000000000000000000000000000000000000..fddf13b9857261bae87e6c2f44ecceb1c5f19324 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-has-property-sym-not-found.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-has-property-sym-not-found.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[HasProperty]] internal method with a symbol argument that cannot be found (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. If Type(P) is Symbol, return OrdinaryHasProperty(O, P). + +---*/ +var sym = Symbol('test262'); + + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(sym in ns, false, 'in'); + assert.sameValue(Reflect.has(ns, sym), false, 'Reflect.has'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-no-iterator.js b/test/language/module-code/dynamic-import/ns/await-ns-no-iterator.js new file mode 100644 index 0000000000000000000000000000000000000000..fe17ef298be533e7e5ebb57a3e1f69da6175b1f8 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-no-iterator.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-no-iterator.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Module namespace objects lack a Symbol.toStringTag (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol.iterator, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(Object.prototype.hasOwnProperty.call(ns, Symbol.iterator), false); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-own-property-keys-sort.js b/test/language/module-code/dynamic-import/ns/await-ns-own-property-keys-sort.js new file mode 100644 index 0000000000000000000000000000000000000000..b4487e09d17009857bc2b3add27aaa5ab18ceea5 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-own-property-keys-sort.js @@ -0,0 +1,130 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-own-property-keys-sort.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[OwnPropertyKeys]] internal method reflects the sorted order (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol.toStringTag, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. Let exports be a copy of the value of O's [[Exports]] internal slot. + 2. Let symbolKeys be ! OrdinaryOwnPropertyKeys(O). + 3. Append all the entries of symbolKeys to the end of exports. + 4. Return exports. + +---*/ + +async function fn() { + const ns = await import('./own-keys-sort_FIXTURE.js'); + + var stringKeys = Object.getOwnPropertyNames(ns); + + assert.sameValue(stringKeys.length, 16); + assert.sameValue(stringKeys[0], '$', 'stringKeys[0] === "$"'); + assert.sameValue(stringKeys[1], '$$', 'stringKeys[1] === "$$"'); + assert.sameValue(stringKeys[2], 'A', 'stringKeys[2] === "A"'); + assert.sameValue(stringKeys[3], 'Z', 'stringKeys[3] === "Z"'); + assert.sameValue(stringKeys[4], '_', 'stringKeys[4] === "_"'); + assert.sameValue(stringKeys[5], '__', 'stringKeys[5] === "__"'); + assert.sameValue(stringKeys[6], 'a', 'stringKeys[6] === "a"'); + assert.sameValue(stringKeys[7], 'aa', 'stringKeys[7] === "aa"'); + assert.sameValue(stringKeys[8], 'az', 'stringKeys[8] === "az"'); + assert.sameValue(stringKeys[9], 'default', 'stringKeys[9] === "default"'); + assert.sameValue(stringKeys[10], 'z', 'stringKeys[10] === "z"'); + assert.sameValue(stringKeys[11], 'za', 'stringKeys[11] === "za"'); + assert.sameValue(stringKeys[12], 'zz', 'stringKeys[12] === "zz"'); + assert.sameValue(stringKeys[13], '\u03bb', 'stringKeys[13] === "\u03bb"'); + assert.sameValue(stringKeys[14], '\u03bc', 'stringKeys[14] === "\u03bc"'); + assert.sameValue(stringKeys[15], '\u03c0', 'stringKeys[15] === "\u03c0"'); + + var allKeys = Reflect.ownKeys(ns); + assert( + allKeys.length >= 17, + 'at least as many keys as defined by the module and the specification' + ); + assert.sameValue(allKeys[0], '$', 'allKeys[0] === "$"'); + assert.sameValue(allKeys[1], '$$', 'allKeys[1] === "$$"'); + assert.sameValue(allKeys[2], 'A', 'allKeys[2] === "A"'); + assert.sameValue(allKeys[3], 'Z', 'allKeys[3] === "Z"'); + assert.sameValue(allKeys[4], '_', 'allKeys[4] === "_"'); + assert.sameValue(allKeys[5], '__', 'allKeys[5] === "__"'); + assert.sameValue(allKeys[6], 'a', 'allKeys[6] === "a"'); + assert.sameValue(allKeys[7], 'aa', 'allKeys[7] === "aa"'); + assert.sameValue(allKeys[8], 'az', 'allKeys[8] === "az"'); + assert.sameValue(allKeys[9], 'default', 'allKeys[9] === "default"'); + assert.sameValue(allKeys[10], 'z', 'allKeys[10] === "z"'); + assert.sameValue(allKeys[11], 'za', 'allKeys[11] === "za"'); + assert.sameValue(allKeys[12], 'zz', 'allKeys[12] === "zz"'); + assert.sameValue(allKeys[13], '\u03bb', 'allKeys[13] === "\u03bb"'); + assert.sameValue(allKeys[14], '\u03bc', 'allKeys[14] === "\u03bc"'); + assert.sameValue(allKeys[15], '\u03c0', 'allKeys[15] === "\u03c0"'); + assert( + allKeys.indexOf(Symbol.toStringTag) > 15, + 'keys array includes Symbol.toStringTag' + ); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-prevent-extensions-object.js b/test/language/module-code/dynamic-import/ns/await-ns-prevent-extensions-object.js new file mode 100644 index 0000000000000000000000000000000000000000..7fc2708a5d995bcdbcfeb1e66c5bdc0967fd3372 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-prevent-extensions-object.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-prevent-extensions-object.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[PreventExtensions]] internal method returns `true` (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +async function fn() { + const ns = await import('./empty_FIXTURE.js'); + + // This invocation should not throw an exception + Object.preventExtensions(ns); + + assert.sameValue(Reflect.preventExtensions(ns), true); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-prevent-extensions-reflect.js b/test/language/module-code/dynamic-import/ns/await-ns-prevent-extensions-reflect.js new file mode 100644 index 0000000000000000000000000000000000000000..28edbf8fca9e7c8467a134cb3650238a8ce4780e --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-prevent-extensions-reflect.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-prevent-extensions-reflect.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[PreventExtensions]] internal method returns `true` (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +async function fn() { + const ns = await import('./empty_FIXTURE.js'); + + assert.sameValue(Reflect.preventExtensions(ns), true); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-prop-descs.js b/test/language/module-code/dynamic-import/ns/await-ns-prop-descs.js new file mode 100644 index 0000000000000000000000000000000000000000..99362a928294893ea2b077eda40f156ccfa9f3ae --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-prop-descs.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-prop-descs.case +// - src/dynamic-import/namespace/await.template +/*--- +description: imported object properties descriptors (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + // propertyHelper.js is not appropriate for this test because it assumes that + // the object exposes the ordinary object's implementation of [[Get]], [[Set]], +// [[Delete]], and [[OwnPropertyKeys]], which the module namespace exotic +// object does not. +var desc = Object.getOwnPropertyDescriptor(ns, 'default'); + +assert.sameValue(desc.value, 42, 'default: value is 42'); +assert.sameValue(desc.enumerable, true, 'default: is enumerable'); +assert.sameValue(desc.writable, true, 'default: is writable'); +assert.sameValue(desc.configurable, false, 'default: is non-configurable'); + +desc = Object.getOwnPropertyDescriptor(ns, 'local1'); + +assert.sameValue(desc.value, 'Test262', 'local1: value is "Test262"'); +assert.sameValue(desc.enumerable, true, 'local1: is enumerable'); +assert.sameValue(desc.writable, true, 'local1: is writable'); +assert.sameValue(desc.configurable, false, 'local1: is non-configurable'); + +desc = Object.getOwnPropertyDescriptor(ns, 'renamed'); + +assert.sameValue(desc.value, 'TC39', 'renamed: value is TC39"'); +assert.sameValue(desc.enumerable, true, 'renamed: is enumerable'); +assert.sameValue(desc.writable, true, 'renamed: is writable'); +assert.sameValue(desc.configurable, false, 'renamed: is non-configurable'); + +desc = Object.getOwnPropertyDescriptor(ns, 'indirect'); + +assert.sameValue(desc.value, 'Test262', 'indirect: value is Test262"'); +assert.sameValue(desc.enumerable, true, 'indirect: is enumerable'); +assert.sameValue(desc.writable, true, 'indirect: is writable'); +assert.sameValue(desc.configurable, false, 'indirect: is non-configurable'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-prototype.js b/test/language/module-code/dynamic-import/ns/await-ns-prototype.js new file mode 100644 index 0000000000000000000000000000000000000000..c21c6b84fbe50d2e8d22db8ca11af430095549b0 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-prototype.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-prototype.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Module namespace object prototype is null (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(ns instanceof Object, false); + assert.sameValue(Object.getPrototypeOf(ns), null, 'prototype is null'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-set-no-strict.js b/test/language/module-code/dynamic-import/ns/await-ns-set-no-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..858c0275bae8830f3bffe37757f84a3175399ccd --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-set-no-strict.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-no-strict.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[Set]] internal method consistently returns `false`, No Strict Mode (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, noStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. Return false. + +---*/ +var sym = Symbol('test262'); + + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(Reflect.set(ns, 'local1'), false, 'Reflect.set: local1'); + assert.sameValue(ns.local1 = null, null, 'AssignmentExpression: local1'); + + assert.sameValue(Reflect.set(ns, 'local2'), false, 'Reflect.set: local2'); + assert.sameValue(ns.local2 = null, null, 'AssignmentExpression: local2'); + + assert.sameValue(Reflect.set(ns, 'renamed'), false, 'Reflect.set: renamed'); + assert.sameValue(ns.renamed = null, null, 'AssignmentExpression: renamed'); + + assert.sameValue(Reflect.set(ns, 'indirect'), false, 'Reflect.set: indirect'); + assert.sameValue(ns.indirect = null, null, 'AssignmentExpression: indirect'); + + assert.sameValue(Reflect.set(ns, 'default'), false, 'Reflect.set: default'); + assert.sameValue(ns.default = null, null, 'AssignmentExpression: default'); + + assert.sameValue( + Reflect.set(ns, Symbol.toStringTag, null), + false, + 'Reflect.set: Symbol.toStringTag' + ); + assert.sameValue(ns[Symbol.toStringTag] = null, null, 'AssignmentExpression: Symbol.toStringTag'); + + assert.sameValue(Reflect.set(ns, sym), false, 'Reflect.set: sym'); + assert.sameValue(ns[sym] = null, null, 'AssignmentExpression: sym'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-set-prototype-of-null.js b/test/language/module-code/dynamic-import/ns/await-ns-set-prototype-of-null.js new file mode 100644 index 0000000000000000000000000000000000000000..02a75f470a9dd68f6430b77a0f9ff1f38defa012 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-set-prototype-of-null.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-prototype-of-null.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[SetPrototypeOf]] internal method returns `true` if passed `null` (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +async function fn() { + const ns = await import('./empty_FIXTURE.js'); + + assert.sameValue(typeof Object.setPrototypeOf, 'function'); + assert.sameValue(ns, Object.setPrototypeOf(ns, null)); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-set-prototype-of.js b/test/language/module-code/dynamic-import/ns/await-ns-set-prototype-of.js new file mode 100644 index 0000000000000000000000000000000000000000..819f8429cdd988dee463bf1f3bfee0e16be99d02 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-set-prototype-of.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-prototype-of.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[SetPrototypeOf]] internal method returns `false` (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + var newProto = {}; + + assert.sameValue(typeof Object.setPrototypeOf, 'function'); + + assert.throws(TypeError, function() { + Object.setPrototypeOf(ns, newProto); + }); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-set-same-values-no-strict.js b/test/language/module-code/dynamic-import/ns/await-ns-set-same-values-no-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..e5e636b0c9b53a1ab909d6cf8743c64501b1774c --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-set-same-values-no-strict.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-same-values-no-strict.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[Set]] internal method consistently returns `false` even setting the same value - No Strict Mode (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, noStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. Return false. + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(Reflect.set(ns, 'local1', 'Test262'), false, 'Reflect.set: local1'); + assert.sameValue(ns.local1 = 'Test262', 'Test262', 'AssignmentExpression: local1'); + + assert.sameValue(Reflect.set(ns, 'renamed', 'TC39'), false, 'Reflect.set: renamed'); + assert.sameValue(ns.renamed = 'TC39', 'TC39', 'AssignmentExpression: renamed'); + + assert.sameValue(Reflect.set(ns, 'indirect', 'Test262'), false, 'Reflect.set: indirect'); + assert.sameValue(ns.indirect = 'Test262', 'Test262', 'AssignmentExpression: indirect'); + + assert.sameValue(Reflect.set(ns, 'default', 42), false, 'Reflect.set: default'); + assert.sameValue(ns.default = 42, 42, 'AssignmentExpression: default'); + + assert.sameValue( + Reflect.set(ns, Symbol.toStringTag, ns[Symbol.toStringTag]), + false, + 'Reflect.set: Symbol.toStringTag' + ); + assert.sameValue(ns[Symbol.toStringTag] = ns[Symbol.toStringTag], 'Module', 'AssignmentExpression: Symbol.toStringTag'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-set-same-values-strict.js b/test/language/module-code/dynamic-import/ns/await-ns-set-same-values-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..c08d85d95cbec163c0cf8fdd46211c304411cd01 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-set-same-values-strict.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-same-values-strict.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[Set]] internal method consistently returns `false` even setting the same value - Strict Mode (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, onlyStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. Return false. + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(Reflect.set(ns, 'local1', 'Test262'), false, 'Reflect.set: local1'); + assert.throws(TypeError, function() { + ns.local1 = 'Test262'; + }, 'AssignmentExpression: local1'); + + assert.sameValue(Reflect.set(ns, 'renamed', 'TC39'), false, 'Reflect.set: renamed'); + assert.throws(TypeError, function() { + ns.renamed = 'TC39'; + }, 'AssignmentExpression: renamed'); + + assert.sameValue(Reflect.set(ns, 'indirect', 'Test262'), false, 'Reflect.set: indirect'); + assert.throws(TypeError, function() { + ns.indirect = 'Test262'; + }, 'AssignmentExpression: indirect'); + + assert.sameValue(Reflect.set(ns, 'default', 42), false, 'Reflect.set: default'); + assert.throws(TypeError, function() { + ns.default = 42; + }, 'AssignmentExpression: default'); + + assert.sameValue( + Reflect.set(ns, Symbol.toStringTag, ns[Symbol.toStringTag]), + false, + 'Reflect.set: Symbol.toStringTag' + ); + assert.throws(TypeError, function() { + ns[Symbol.toStringTag] = ns[Symbol.toStringTag]; + }, 'AssignmentExpression: Symbol.toStringTag'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-set-strict.js b/test/language/module-code/dynamic-import/ns/await-ns-set-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..31eda654d59f78cfeeed1b7f8e3acec453d8e774 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-set-strict.js @@ -0,0 +1,122 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-strict.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[Set]] internal method consistently returns `false`, Strict Mode (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, onlyStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. Return false. + +---*/ +var sym = Symbol('test262'); + + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(Reflect.set(ns, 'local1'), false, 'Reflect.set: local1'); + assert.throws(TypeError, function() { + ns.local1 = null; + }, 'AssignmentExpression: local1'); + + assert.sameValue(Reflect.set(ns, 'local2'), false, 'Reflect.set: local2'); + assert.throws(TypeError, function() { + ns.local2 = null; + }, 'AssignmentExpression: local2'); + + assert.sameValue(Reflect.set(ns, 'renamed'), false, 'Reflect.set: renamed'); + assert.throws(TypeError, function() { + ns.renamed = null; + }, 'AssignmentExpression: renamed'); + + assert.sameValue(Reflect.set(ns, 'indirect'), false, 'Reflect.set: indirect'); + assert.throws(TypeError, function() { + ns.indirect = null; + }, 'AssignmentExpression: indirect'); + + assert.sameValue(Reflect.set(ns, 'default'), false, 'Reflect.set: default'); + assert.throws(TypeError, function() { + ns.default = null; + }, 'AssignmentExpression: default'); + + assert.sameValue( + Reflect.set(ns, Symbol.toStringTag, null), + false, + 'Reflect.set: Symbol.toStringTag' + ); + assert.throws(TypeError, function() { + ns[Symbol.toStringTag] = null; + }, 'AssignmentExpression: Symbol.toStringTag'); + + assert.sameValue(Reflect.set(ns, sym), false, 'Reflect.set: sym'); + assert.throws(TypeError, function() { + ns[sym] = null; + }, 'AssignmentExpression: sym'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/define-own-property_FIXTURE.js b/test/language/module-code/dynamic-import/ns/define-own-property_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..050f79c1d137e37e451fd0611a7d5a64c55b94f8 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/define-own-property_FIXTURE.js @@ -0,0 +1,7 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export var local1; +var local2; +export { local2 as renamed }; +export { local1 as indirect } from './define-own-property_FIXTURE.js'; diff --git a/test/language/module-code/dynamic-import/ns/empty_FIXTURE.js b/test/language/module-code/dynamic-import/ns/empty_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..96a3b859540e61f86365c67174131736beab9785 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/empty_FIXTURE.js @@ -0,0 +1,2 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. diff --git a/test/language/module-code/dynamic-import/ns/get-nested-namespace-dflt-skip-named-end_FIXTURE.js b/test/language/module-code/dynamic-import/ns/get-nested-namespace-dflt-skip-named-end_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..510e2b66423ad930a5df30c69d7c1e6fda9cfff2 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/get-nested-namespace-dflt-skip-named-end_FIXTURE.js @@ -0,0 +1,6 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +var x = 42; +export var namedOther = null; +export { x as default }; diff --git a/test/language/module-code/dynamic-import/ns/get-nested-namespace-dflt-skip-named_FIXTURE.js b/test/language/module-code/dynamic-import/ns/get-nested-namespace-dflt-skip-named_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..fbd2343b7a4a92411876caa761edbffc878d5dbd --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/get-nested-namespace-dflt-skip-named_FIXTURE.js @@ -0,0 +1,4 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export * as namedNS2 from './get-nested-namespace-dflt-skip-named-end_FIXTURE.js'; diff --git a/test/language/module-code/dynamic-import/ns/get-nested-namespace-dflt-skip-prod-end_FIXTURE.js b/test/language/module-code/dynamic-import/ns/get-nested-namespace-dflt-skip-prod-end_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..3343f91a541c5e125e200895f045f1109d9af4c6 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/get-nested-namespace-dflt-skip-prod-end_FIXTURE.js @@ -0,0 +1,5 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export var productionOther = null; +export default 42; diff --git a/test/language/module-code/dynamic-import/ns/get-nested-namespace-dflt-skip-prod_FIXTURE.js b/test/language/module-code/dynamic-import/ns/get-nested-namespace-dflt-skip-prod_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..a626c903ab458ae2ab90652c19c4e6600b59045a --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/get-nested-namespace-dflt-skip-prod_FIXTURE.js @@ -0,0 +1,4 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export * as productionNS2 from './get-nested-namespace-dflt-skip-prod-end_FIXTURE.js'; diff --git a/test/language/module-code/dynamic-import/ns/get-nested-namespace-props-nrml-1_FIXTURE.js b/test/language/module-code/dynamic-import/ns/get-nested-namespace-props-nrml-1_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..c3b3ea40c51f4cd00541f58443d364945a9110ba --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/get-nested-namespace-props-nrml-1_FIXTURE.js @@ -0,0 +1,4 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export * as exportns from './get-nested-namespace-props-nrml-2_FIXTURE.js'; diff --git a/test/language/module-code/dynamic-import/ns/get-nested-namespace-props-nrml-2_FIXTURE.js b/test/language/module-code/dynamic-import/ns/get-nested-namespace-props-nrml-2_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..8e3281868d4de00ed9bed5dc5a2dfa197a618e1e --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/get-nested-namespace-props-nrml-2_FIXTURE.js @@ -0,0 +1,23 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +var notExportedVar; +let notExportedLet; +const notExportedConst = null; +function notExportedFunc() {} +function* notExportedGen() {} +class notExportedClass {} + +var starAsBindingId; + +export var starAsVarDecl; +export let starAsLetDecl; +export const starAsConstDecl = null; +export function starAsFuncDecl() {} +export function* starAsGenDecl() {} +export class starAsClassDecl {} +export { starAsBindingId }; +export { starAsBindingId as starIdName }; +export { starAsIndirectIdName } from './get-nested-namespace-props-nrml-3_FIXTURE.js'; +export { starAsIndirectIdName as starAsIndirectIdName2 } from './get-nested-namespace-props-nrml-3_FIXTURE.js'; +export * as namespaceBinding from './get-nested-namespace-props-nrml-3_FIXTURE.js';; diff --git a/test/language/module-code/dynamic-import/ns/get-nested-namespace-props-nrml-3_FIXTURE.js b/test/language/module-code/dynamic-import/ns/get-nested-namespace-props-nrml-3_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..0c1192c1adb2382730817bb393ee09093f4269d5 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/get-nested-namespace-props-nrml-3_FIXTURE.js @@ -0,0 +1,5 @@ +// Copyright (C) 2016 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export var indirectIdName; +export var starAsIndirectIdName; diff --git a/test/language/module-code/dynamic-import/ns/module-code_FIXTURE.js b/test/language/module-code/dynamic-import/ns/module-code_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..62cb5ae82193f19df0c8d2e70dfc7214437e8771 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/module-code_FIXTURE.js @@ -0,0 +1,10 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +// exports: default === 42, local1 === 'Test262', renamed === 'TC39', indirect === 'Test262' + +export var local1 = 'Test262'; +var local2 = 'TC39'; +export { local2 as renamed }; +export { local1 as indirect } from './module-code_FIXTURE.js'; +export default 42; diff --git a/test/language/module-code/dynamic-import/ns/own-keys-sort_FIXTURE.js b/test/language/module-code/dynamic-import/ns/own-keys-sort_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..baa8645460da9d0393010cafe35b4796d3308744 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/own-keys-sort_FIXTURE.js @@ -0,0 +1,20 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +var x; +export { x as π }; // u03c0 +export { x as az }; +export { x as __ }; +export { x as za }; +export { x as Z }; +export { x as \u03bc }; +export { x as z }; +export { x as zz }; +export { x as a }; +export { x as A }; +export { x as aa }; +export { x as λ }; // u03bb +export { x as _ }; +export { x as $$ }; +export { x as $ }; +export default null; diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-Symbol-toStringTag.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-Symbol-toStringTag.js new file mode 100644 index 0000000000000000000000000000000000000000..bb0e5f68d8d4e7098360a96708fde5a4856280e6 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-Symbol-toStringTag.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-Symbol-toStringTag.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Module namespace objects have a Symbol.toStringTag (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol.toStringTag, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: false }. + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(ns[Symbol.toStringTag], 'Module'); + + // propertyHelper.js is not appropriate for this test because it assumes that + // the object exposes the ordinary object's implementation of [[Get]], [[Set]], +// [[Delete]], and [[OwnPropertyKeys]], which the module namespace exotic +// object does not. +var desc = Object.getOwnPropertyDescriptor(ns, Symbol.toStringTag); + +assert.sameValue(desc.enumerable, false, 'reports as non-enumerable'); +assert.sameValue(desc.writable, false, 'reports as non-writable'); +assert.sameValue(desc.configurable, false, 'reports as non-configurable'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-define-own-property.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-define-own-property.js new file mode 100644 index 0000000000000000000000000000000000000000..e746ede5a8f9687d1f70a50912a185826963f130 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-define-own-property.js @@ -0,0 +1,175 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-define-own-property.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[DefineOwnProperty]] internal method returns `true` if no change is requested, and `false` otherwise. (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol.iterator, Reflect, Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ +var sym = Symbol('test262'); + +const exported = ['local1', 'renamed', 'indirect']; + + +import('./define-own-property_FIXTURE.js').then(ns => { + + // Non-existant properties. + + for (const key of ['local2', 0, sym, Symbol.iterator]) { + assert.sameValue( + Reflect.defineProperty(ns, key, {}), + false, + 'Reflect.defineProperty: ' + key.toString() + ); + assert.throws(TypeError, function() { + Object.defineProperty(ns, key, {}); + }, 'Object.defineProperty: ' + key.toString()); + } + + // Own properties. No change requested. + + for (const key of ([...exported, Symbol.toStringTag])) { + assert.sameValue( + Reflect.defineProperty(ns, key, {}), + true, + `No change requested, Reflect.defineProperty: ${key.toString()}` + ); + assert.sameValue( + Object.defineProperty(ns, key, {}), + ns, + `No change requested, Object.defineProperty: ${key.toString()}` + ); + + } + + assert.sameValue( + Reflect.defineProperty(ns, 'indirect', + {writable: true, enumerable: true, configurable: false}), + true, + 'Reflect.defineProperty: indirect' + ); + assert.sameValue( + Object.defineProperty(ns, 'indirect', + {writable: true, enumerable: true, configurable: false}), + ns, + 'Object.defineProperty: indirect' + ); + + assert.sameValue( + Reflect.defineProperty(ns, Symbol.toStringTag, + {value: "Module", writable: false, enumerable: false, + configurable: false}), + true, + 'Reflect.defineProperty: Symbol.toStringTag' + ); + assert.sameValue( + Object.defineProperty(ns, Symbol.toStringTag, + {value: "Module", writable: false, enumerable: false, + configurable: false}), + ns, + 'Object.defineProperty: Symbol.toStringTag' + ); + + + // Own properties. Change requested. + + for (const key of ([...exported, Symbol.toStringTag])) { + assert.sameValue( + Reflect.defineProperty(ns, key, {value: 123}), + false, + `Change requested, Reflect.defineProperty: ${key.toString()}` + ); + assert.throws(TypeError, function() { + Object.defineProperty(ns, key, {value: 123}); + }, `Change requested, Object.defineProperty: ${key.toString()}`); + } + + assert.sameValue( + Reflect.defineProperty(ns, 'indirect', + {writable: true, enumerable: true, configurable: true}), + false, + 'Reflect.defineProperty: indirect' + ); + assert.throws(TypeError, function() { + Object.defineProperty(ns, 'indirect', + {writable: true, enumerable: true, configurable: true}); + }, 'Object.defineProperty: indirect'); + + assert.sameValue( + Reflect.defineProperty(ns, Symbol.toStringTag, + {value: "module", writable: false, enumerable: false, + configurable: false}), + false, + 'Reflect.defineProperty: Symbol.toStringTag' + ); + assert.throws(TypeError, function() { + Object.defineProperty(ns, Symbol.toStringTag, + {value: "module", writable: false, enumerable: false, + configurable: false}); + }, 'Object.defineProperty: Symbol.toStringTag'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-exported-init-no-strict.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-exported-init-no-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..39847dde754590ea0c1625b0978cea11e0048de7 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-exported-init-no-strict.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-delete-exported-init-no-strict.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[Delete]] behavior for a key that describes an initialized exported binding on non strict mode (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, noStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryDelete(O, P). + 3. Let exports be O.[[Exports]]. + 4. If P is an element of exports, return false. + 5. Return true. + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(delete ns.default, false, 'delete: default'); + assert.sameValue( + Reflect.deleteProperty(ns, 'default'), false, 'Reflect.deleteProperty: default' + ); + assert.sameValue(ns.default, 42, 'binding unmodified: default'); + + assert.sameValue(delete ns.local1, false, 'delete: local1'); + assert.sameValue( + Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1' + ); + assert.sameValue(ns.local1, 'Test262', 'binding unmodified: local1'); + + assert.sameValue(delete ns.renamed, false, 'delete: renamed'); + assert.sameValue( + Reflect.deleteProperty(ns, 'renamed'), false, 'Reflect.deleteProperty: renamed' + ); + assert.sameValue(ns.renamed, 'TC39', 'binding unmodified: renamed'); + + assert.sameValue(delete ns.indirect, false, 'delete: indirect'); + assert.sameValue( + Reflect.deleteProperty(ns, 'indirect'), + false, + 'Reflect.deleteProperty: indirect' + ); + assert.sameValue(ns.indirect, 'Test262', 'binding unmodified: indirect'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-exported-init-strict.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-exported-init-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..c8fad64d43e51b50e9f0aecd9db234b509d3b366 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-exported-init-strict.js @@ -0,0 +1,118 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-delete-exported-init-strict.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[Delete]] behavior for a key that describes an initialized exported binding on strict mode (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, onlyStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryDelete(O, P). + 3. Let exports be O.[[Exports]]. + 4. If P is an element of exports, return false. + 5. Return true. + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + assert.throws(TypeError, function() { + delete ns.default; + }, 'delete: default'); + assert.sameValue( + Reflect.deleteProperty(ns, 'default'), false, 'Reflect.deleteProperty: default' + ); + assert.sameValue(ns.default, 42, 'binding unmodified: default'); + + assert.throws(TypeError, function() { + delete ns.local1; + }, 'delete: local1'); + assert.sameValue( + Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1' + ); + assert.sameValue(ns.local1, 'Test262', 'binding unmodified: local1'); + + assert.throws(TypeError, function() { + delete ns.renamed; + }, 'delete: renamed'); + assert.sameValue( + Reflect.deleteProperty(ns, 'renamed'), false, 'Reflect.deleteProperty: renamed' + ); + assert.sameValue(ns.renamed, 'TC39', 'binding unmodified: renamed'); + + assert.throws(TypeError, function() { + delete ns.indirect; + }, 'delete: indirect'); + assert.sameValue( + Reflect.deleteProperty(ns, 'indirect'), + false, + 'Reflect.deleteProperty: indirect' + ); + assert.sameValue(ns.indirect, 'Test262', 'binding unmodified: indirect'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-non-exported-no-strict.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-non-exported-no-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..88b707c8d00e364808788f99a98764ab1ce61b06 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-non-exported-no-strict.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-delete-non-exported-no-strict.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[Delete]] behavior for a key that does not describe an exported binding (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, noStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryDelete(O, P). + 3. Let exports be O.[[Exports]]. + 4. If P is an element of exports, return false. + 5. Return true. + +---*/ + +import('./empty_FIXTURE.js').then(ns => { + + assert(delete ns.undef, 'delete: undef'); + assert(Reflect.deleteProperty(ns, 'undef'), 'Reflect.deleteProperty: undef'); + + assert(delete ns.default, 'delete: default'); + assert( + Reflect.deleteProperty(ns, 'default'), 'Reflect.deleteProperty: default' + ); + + assert.sameValue(delete ns[Symbol.toStringTag], false, 'delete: Symbol.toStringTag'); + assert.sameValue( + Reflect.deleteProperty(ns, Symbol.toStringTag), false, + 'Reflect.deleteProperty: Symbol.toStringTag' + ); + + var sym = Symbol('test262'); + assert(delete ns[sym], 'delete: symbol'); + assert(Reflect.deleteProperty(ns, sym), 'Reflect.deleteProperty: symbol'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-non-exported-strict.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-non-exported-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..700ee431f8b5dbb4e64f6d60ddd83b4e46425e36 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-non-exported-strict.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-delete-non-exported-strict.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[Delete]] behavior for a key that does not describe an exported binding (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, onlyStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryDelete(O, P). + 3. Let exports be O.[[Exports]]. + 4. If P is an element of exports, return false. + 5. Return true. + +---*/ + +import('./empty_FIXTURE.js').then(ns => { + + assert(delete ns.undef, 'delete: undef'); + assert(Reflect.deleteProperty(ns, 'undef'), 'Reflect.deleteProperty: undef'); + + assert(delete ns.default, 'delete: default'); + assert( + Reflect.deleteProperty(ns, 'default'), 'Reflect.deleteProperty: default' + ); + + assert.sameValue( + Reflect.deleteProperty(ns, Symbol.toStringTag), false, + 'Reflect.deleteProperty: Symbol.toStringTag' + ); + assert.throws(TypeError, function() { delete ns[Symbol.toStringTag]; }, 'delete: Symbol.toStringTag'); + + var sym = Symbol('test262'); + assert(delete ns[sym], 'delete: symbol'); + assert(Reflect.deleteProperty(ns, sym), 'Reflect.deleteProperty: symbol'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-extensible.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-extensible.js new file mode 100644 index 0000000000000000000000000000000000000000..28a628d21178c25192db3691b338ffbafdefa71a --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-extensible.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-extensible.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Module namespace objects are not extensible. (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(Object.isExtensible(ns), false); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-get-nested-namespace-dflt-direct.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-nested-namespace-dflt-direct.js new file mode 100644 index 0000000000000000000000000000000000000000..2125506f3d1bd8a75269cfaf2a6389dc9eb717c3 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-nested-namespace-dflt-direct.js @@ -0,0 +1,124 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-nested-namespace-dflt-direct.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Direct Default exports are included in an imported module namespace object when a namespace object is created. (value from promise then) +esid: sec-finishdynamicimport +features: [export-star-as-namespace-from-module, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 6. Let binding be ! m.ResolveExport(P, « »). + 7. Assert: binding is a ResolvedBinding Record. + 8. Let targetModule be binding.[[Module]]. + 9. Assert: targetModule is not undefined. + 10. If binding.[[BindingName]] is "*namespace*", then + 11. Return ? GetModuleNamespace(targetModule). + + Runtime Semantics: GetModuleNamespace + [...] + 3. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, + i. Let resolution be ? module.ResolveExport(name, « », « »). + ii. If resolution is null, throw a SyntaxError exception. + iii. If resolution is not "ambiguous", append name to + unambiguousNames. + d. Let namespace be ModuleNamespaceCreate(module, unambiguousNames). + [...] + +---*/ + +import('./get-nested-namespace-dflt-skip-prod_FIXTURE.js').then(ns => { + + var desc = Object.getOwnPropertyDescriptor(ns, 'productionNS2'); + + assert.sameValue(desc.enumerable, true, 'ns.productionNS2: is enumerable'); + assert.sameValue(desc.writable, true, 'ns.productionNS2: is writable'); + assert.sameValue(desc.configurable, false, 'ns.productionNS2: is non-configurable'); + + var keys = Object.keys(ns.productionNS2); + + assert.sameValue(keys.length, 2); + assert.sameValue(keys[0], 'default'); + assert.sameValue(keys[1], 'productionOther'); + + desc = Object.getOwnPropertyDescriptor(ns.productionNS2, 'productionOther'); + + assert.sameValue(desc.value, null, 'ns.productionNS2.productionOther: value is null'); + assert.sameValue(desc.enumerable, true, 'ns.productionNS2.productionOther: is enumerable'); + assert.sameValue(desc.writable, true, 'ns.productionNS2.productionOther: is writable'); + assert.sameValue(desc.configurable, false, 'ns.productionNS2.productionOther: is non-configurable'); + + desc = Object.getOwnPropertyDescriptor(ns.productionNS2, 'default'); + + assert.sameValue(desc.value, 42, 'ns.productionNS2.default value is 42'); + assert.sameValue(desc.enumerable, true, 'ns.productionNS2.default is enumerable'); + assert.sameValue(desc.writable, true, 'ns.productionNS2.default is writable'); + assert.sameValue(desc.configurable, false, 'ns.productionNS2.default is non-configurable'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-get-nested-namespace-dflt-indirect.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-nested-namespace-dflt-indirect.js new file mode 100644 index 0000000000000000000000000000000000000000..a505ba70e691947d23f8c184859382a467809064 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-nested-namespace-dflt-indirect.js @@ -0,0 +1,124 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-nested-namespace-dflt-indirect.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Inirect Default exports are included in an imported module namespace object when a namespace object is created. (value from promise then) +esid: sec-finishdynamicimport +features: [export-star-as-namespace-from-module, dynamic-import] +flags: [generated, module, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 6. Let binding be ! m.ResolveExport(P, « »). + 7. Assert: binding is a ResolvedBinding Record. + 8. Let targetModule be binding.[[Module]]. + 9. Assert: targetModule is not undefined. + 10. If binding.[[BindingName]] is "*namespace*", then + 11. Return ? GetModuleNamespace(targetModule). + + Runtime Semantics: GetModuleNamespace + [...] + 3. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, + i. Let resolution be ? module.ResolveExport(name, « », « »). + ii. If resolution is null, throw a SyntaxError exception. + iii. If resolution is not "ambiguous", append name to + unambiguousNames. + d. Let namespace be ModuleNamespaceCreate(module, unambiguousNames). + [...] + +---*/ + +import('./get-nested-namespace-dflt-skip-named_FIXTURE.js').then(ns => { + + var desc = Object.getOwnPropertyDescriptor(ns, 'namedNS2'); + + assert.sameValue(desc.enumerable, true, 'ns.namedNS2: is enumerable'); + assert.sameValue(desc.writable, true, 'ns.namedNS2: is writable'); + assert.sameValue(desc.configurable, false, 'ns.namedNS2: is non-configurable'); + + var keys = Object.keys(ns.namedNS2); + + assert.sameValue(keys.length, 2); + assert.sameValue(keys[0], 'default'); + assert.sameValue(keys[1], 'namedOther'); + + desc = Object.getOwnPropertyDescriptor(ns.namedNS2, 'namedOther'); + + assert.sameValue(desc.value, null, 'ns.namedNS2.namedOther value is null'); + assert.sameValue(desc.enumerable, true, 'ns.namedNS2.namedOther: is enumerable'); + assert.sameValue(desc.writable, true, 'ns.namedNS2.namedOther: is writable'); + assert.sameValue(desc.configurable, false, 'ns.namedNS2.namedOther: is non-configurable'); + + desc = Object.getOwnPropertyDescriptor(ns.namedNS2, 'default'); + + assert.sameValue(desc.value, 42, 'ns.namedNS2.default value is 42'); + assert.sameValue(desc.enumerable, true, 'ns.namedNS2.default is enumerable'); + assert.sameValue(desc.writable, true, 'ns.namedNS2.default is writable'); + assert.sameValue(desc.configurable, false, 'ns.namedNS2.default is non-configurable'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-get-nested-namespace-props-nrml.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-nested-namespace-props-nrml.js new file mode 100644 index 0000000000000000000000000000000000000000..7dfe3eadef764d38394f837afc731b3cb4333759 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-nested-namespace-props-nrml.js @@ -0,0 +1,121 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-nested-namespace-props-nrml.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Module namespace object reports properties for all ExportEntries of all dependencies. (value from promise then) +esid: sec-finishdynamicimport +features: [export-star-as-namespace-from-module, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 12. For each ImportEntry Record in in module.[[ImportEntries]], do + a. Let importedModule be ? HostResolveImportedModule(module, + in.[[ModuleRequest]]). + b. If in.[[ImportName]] is "*", then + i. Let namespace be ? GetModuleNamespace(importedModule). + [...] + + Runtime Semantics: GetModuleNamespace + 3. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, + i. Let resolution be ? module.ResolveExport(name, « », « »). + ii. If resolution is null, throw a SyntaxError exception. + iii. If resolution is not "ambiguous", append name to + unambiguousNames. + d. Let namespace be ModuleNamespaceCreate(module, unambiguousNames). + +---*/ +function hasOwnProperty(obj, property) { + return Object.prototype.hasOwnProperty.call(obj, property); +} + + +import('./get-nested-namespace-props-nrml-1_FIXTURE.js').then(ns => { + + // Export entries defined by a re-exported as exportns module + assert(hasOwnProperty(ns.exportns, 'starAsVarDecl'), 'starssVarDecl'); + assert(hasOwnProperty(ns.exportns, 'starAsLetDecl'), 'starSsLetDecl'); + assert(hasOwnProperty(ns.exportns, 'starAsConstDecl'), 'starSsConstDecl'); + assert(hasOwnProperty(ns.exportns, 'starAsFuncDecl'), 'starAsFuncDecl'); + assert(hasOwnProperty(ns.exportns, 'starAsGenDecl'), 'starAsGenDecl'); + assert(hasOwnProperty(ns.exportns, 'starAsClassDecl'), 'starAsClassDecl'); + assert(hasOwnProperty(ns.exportns, 'starAsBindingId'), 'starAsBindingId'); + assert(hasOwnProperty(ns.exportns, 'starIdName'), 'starIdName'); + assert(hasOwnProperty(ns.exportns, 'starAsIndirectIdName'), 'starAsIndirectIdName'); + assert(hasOwnProperty(ns.exportns, 'starAsIndirectIdName2'), 'starAsIndirectIdName2'); + assert(hasOwnProperty(ns.exportns, 'namespaceBinding'), 'namespaceBinding'); + + // Bindings that were not exported from any module + assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedVar'), false, 'nonExportedVar'); + assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedLet'), false, 'nonExportedLet'); + assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedConst'), false, 'nonExportedConst'); + assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedFunc'), false, 'nonExportedFunc'); + assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedGen'), false, 'nonExportedGen'); + assert.sameValue(hasOwnProperty(ns.exportns, 'nonExportedClass'), false, 'nonExportedClass'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-get-own-property-str-found-init.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-own-property-str-found-init.js new file mode 100644 index 0000000000000000000000000000000000000000..5652eef1194a79476b68a477acd8865916d61c02 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-own-property-str-found-init.js @@ -0,0 +1,122 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-own-property-str-found-init.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[GetOwnProperty]] internal method with a string argument describing an initialized binding (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. If Type(P) is Symbol, return OrdinaryGetOwnProperty(O, P). + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is not an element of exports, return undefined. + 4. Let value be ? O.[[Get]](P, O). + 5. Return PropertyDescriptor{[[Value]]: value, [[Writable]]: true, + [[Enumerable]]: true, [[Configurable]]: false }. + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + var desc; + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'local1'), true + ); + desc = Object.getOwnPropertyDescriptor(ns, 'local1'); + assert.sameValue(desc.value, 'Test262'); + assert.sameValue(desc.enumerable, true, 'local1 enumerable'); + assert.sameValue(desc.writable, true, 'local1 writable'); + assert.sameValue(desc.configurable, false, 'local1 configurable'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'renamed'), true + ); + desc = Object.getOwnPropertyDescriptor(ns, 'renamed'); + assert.sameValue(desc.value, 'TC39'); + assert.sameValue(desc.enumerable, true, 'renamed enumerable'); + assert.sameValue(desc.writable, true, 'renamed writable'); + assert.sameValue(desc.configurable, false, 'renamed configurable'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'indirect'), true + ); + desc = Object.getOwnPropertyDescriptor(ns, 'indirect'); + assert.sameValue(desc.value, 'Test262'); + assert.sameValue(desc.enumerable, true, 'indirect enumerable'); + assert.sameValue(desc.writable, true, 'indirect writable'); + assert.sameValue(desc.configurable, false, 'indirect configurable'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'default'), true + ); + desc = Object.getOwnPropertyDescriptor(ns, 'default'); + assert.sameValue(desc.value, 42); + assert.sameValue(desc.enumerable, true, 'default enumerable'); + assert.sameValue(desc.writable, true, 'default writable'); + assert.sameValue(desc.configurable, false, 'default configurable'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-get-own-property-str-not-found.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-own-property-str-not-found.js new file mode 100644 index 0000000000000000000000000000000000000000..7e3e40c2d81e9610376242cafe1bb70568931817 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-own-property-str-not-found.js @@ -0,0 +1,115 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-own-property-str-not-found.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[GetOwnProperty]] internal method with a string argument describing a binding that cannot be found (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. If Type(P) is Symbol, return OrdinaryGetOwnProperty(O, P). + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is not an element of exports, return undefined. + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + var desc; + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'local2'), + false, + 'hasOwnProperty: local2' + ); + desc = Object.getOwnPropertyDescriptor(ns, 'local2'); + assert.sameValue(desc, undefined, 'property descriptor for "local2"'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'toStringTag'), + false, + 'hasOwnProperty: toStringTag' + ); + desc = Object.getOwnPropertyDescriptor(ns, 'toStringTag'); + assert.sameValue(desc, undefined, 'property descriptor for "toStringTag"'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'iterator'), + false, + 'hasOwnProperty: iterator' + ); + desc = Object.getOwnPropertyDescriptor(ns, 'iterator'); + assert.sameValue(desc, undefined, 'property descriptor for "iterator"'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, '__proto__'), + false, + 'hasOwnProperty: __proto__' + ); + desc = Object.getOwnPropertyDescriptor(ns, '__proto__'); + assert.sameValue(desc, undefined, 'property descriptor for "__proto__"'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-get-own-property-sym.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-own-property-sym.js new file mode 100644 index 0000000000000000000000000000000000000000..6824a10f98a8d14c23d65b251949261240be83f6 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-own-property-sym.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-own-property-sym.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[GetOwnProperty]] internal method with a Symbol argument (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ +var notFound = Symbol('test262'); + + +import('./module-code_FIXTURE.js').then(ns => { + + var desc; + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, Symbol.toStringTag), true + ); + desc = Object.getOwnPropertyDescriptor(ns, Symbol.toStringTag); + assert.sameValue(desc.value, ns[Symbol.toStringTag]); + assert.sameValue(desc.enumerable, false, 'Symbol.toStringTag enumerable'); + assert.sameValue(desc.writable, false, 'Symbol.toStringTag writable'); + assert.sameValue(desc.configurable, false, 'Symbol.toStringTag configurable'); + + assert.sameValue(Object.prototype.hasOwnProperty.call(ns, notFound), false); + desc = Object.getOwnPropertyDescriptor(ns, notFound); + assert.sameValue(desc, undefined); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-get-str-found.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-str-found.js new file mode 100644 index 0000000000000000000000000000000000000000..7322efc5412909d8bd457aa81e7e72b138b0e469 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-str-found.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-str-found.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[Get]] internal method with a string argument for exported initialized bindings. (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 12. Let targetEnvRec be targetEnv's EnvironmentRecord. + 13. Return ? targetEnvRec.GetBindingValue(binding.[[BindingName]], true). + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(ns.local1, 'Test262'); + assert.sameValue(ns.renamed, 'TC39'); + assert.sameValue(ns.indirect, 'Test262'); + assert.sameValue(ns.default, 42); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-get-str-not-found.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-str-not-found.js new file mode 100644 index 0000000000000000000000000000000000000000..bae537b0d58f57d4b0c350168298da43fcd1c0e4 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-str-not-found.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-str-not-found.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[Get]] internal method with a string argument for non-exported bindings (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 3. Let exports be the value of O's [[Exports]] internal slot. + 4. If P is not an element of exports, return undefined. + +---*/ +var local2; // not used + + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(ns.local2, undefined, 'key: local2'); + assert.sameValue(ns.toStringTag, undefined, 'key: toStringTag'); + assert.sameValue(ns.iterator, undefined, 'key: iterator'); + assert.sameValue(ns.__proto__, undefined, 'key: __proto__'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-get-sym-found.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-sym-found.js new file mode 100644 index 0000000000000000000000000000000000000000..f2f4e20cfb4ca99a4830b7174b85e406fb2f539c --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-sym-found.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-sym-found.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[Get]] internal method with a symbol argument that can be found (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol.toStringTag, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryGet(O, P, Receiver). + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(typeof ns[Symbol.toStringTag], 'string'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-get-sym-not-found.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-sym-not-found.js new file mode 100644 index 0000000000000000000000000000000000000000..d34090ff6b645e39d6c3ccdc71b0e06ed8085111 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-sym-not-found.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-sym-not-found.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[Get]] internal method with a symbol argument that cannot be found (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryGet(O, P, Receiver). + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(ns[Symbol('test262')], undefined, 'Symbol: test262'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-str-found-init.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-str-found-init.js new file mode 100644 index 0000000000000000000000000000000000000000..b142bc0aff510547e24a9e8e5d6e4a1ee2abdef9 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-str-found-init.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-has-property-str-found-init.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[HasProperty]] internal method with a string argument for exported initialized bindings. (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is an element of exports, return true. + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + assert('local1' in ns, 'in: local1'); + assert(Reflect.has(ns, 'local1'), 'Reflect.has: local1'); + + assert('renamed' in ns, 'in: renamed'); + assert(Reflect.has(ns, 'renamed'), 'Reflect.has: renamed'); + + assert('indirect' in ns, 'in: indirect'); + assert(Reflect.has(ns, 'indirect'), 'Reflect.has: indirect'); + + assert('default' in ns, 'in: default'); + assert(Reflect.has(ns, 'default'), 'Reflect.has: default'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-str-not-found.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-str-not-found.js new file mode 100644 index 0000000000000000000000000000000000000000..acaef1dd025bc4ed76756e86268034ba30f291ba --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-str-not-found.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-has-property-str-not-found.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[HasProperty]] internal method with a string argument for non-exported bindings (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is an element of exports, return true. + 4. Return false. + +---*/ +var local2; // not used + + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue('local2' in ns, false, 'in: local2'); + assert.sameValue(Reflect.has(ns, 'local2'), false, 'Reflect.has: local2'); + + assert.sameValue('toStringTag' in ns, false, 'in: toStringTag'); + assert.sameValue( + Reflect.has(ns, 'toStringTag'), false, 'Reflect.has: toStringTag' + ); + + assert.sameValue('iterator' in ns, false, 'in: iterator'); + assert.sameValue(Reflect.has(ns, 'iterator'), false, 'Reflect.has: iterator'); + + assert.sameValue('__proto__' in ns, false, 'in: __proto__'); + assert.sameValue( + Reflect.has(ns, '__proto__'), false, 'Reflect.has: __proto__' + ); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-sym-found.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-sym-found.js new file mode 100644 index 0000000000000000000000000000000000000000..890a6127b1ceef035699d6ecafe6c82d0ef007c7 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-sym-found.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-has-property-sym-found.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[HasProperty]] internal method with a symbol argument that can be found (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol.toStringTag, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. If Type(P) is Symbol, return OrdinaryHasProperty(O, P). + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + assert(Symbol.toStringTag in ns, 'in: Symbol.toStringTag'); + assert(Reflect.has(ns, Symbol.toStringTag), 'Reflect.has: Symbol.toStringTag'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-sym-not-found.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-sym-not-found.js new file mode 100644 index 0000000000000000000000000000000000000000..d737f6a66b0c4d1a6feb7dd2fce992c513ac5a77 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-sym-not-found.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-has-property-sym-not-found.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[HasProperty]] internal method with a symbol argument that cannot be found (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. If Type(P) is Symbol, return OrdinaryHasProperty(O, P). + +---*/ +var sym = Symbol('test262'); + + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(sym in ns, false, 'in'); + assert.sameValue(Reflect.has(ns, sym), false, 'Reflect.has'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-no-iterator.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-no-iterator.js new file mode 100644 index 0000000000000000000000000000000000000000..d8e507273bf7cede15c945912491b2aa58a6dbcb --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-no-iterator.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-no-iterator.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Module namespace objects lack a Symbol.toStringTag (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol.iterator, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(Object.prototype.hasOwnProperty.call(ns, Symbol.iterator), false); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-own-property-keys-sort.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-own-property-keys-sort.js new file mode 100644 index 0000000000000000000000000000000000000000..d773959f10e07ff614de6384b51a0f5ac654988c --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-own-property-keys-sort.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-own-property-keys-sort.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[OwnPropertyKeys]] internal method reflects the sorted order (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol.toStringTag, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. Let exports be a copy of the value of O's [[Exports]] internal slot. + 2. Let symbolKeys be ! OrdinaryOwnPropertyKeys(O). + 3. Append all the entries of symbolKeys to the end of exports. + 4. Return exports. + +---*/ + +import('./own-keys-sort_FIXTURE.js').then(ns => { + + var stringKeys = Object.getOwnPropertyNames(ns); + + assert.sameValue(stringKeys.length, 16); + assert.sameValue(stringKeys[0], '$', 'stringKeys[0] === "$"'); + assert.sameValue(stringKeys[1], '$$', 'stringKeys[1] === "$$"'); + assert.sameValue(stringKeys[2], 'A', 'stringKeys[2] === "A"'); + assert.sameValue(stringKeys[3], 'Z', 'stringKeys[3] === "Z"'); + assert.sameValue(stringKeys[4], '_', 'stringKeys[4] === "_"'); + assert.sameValue(stringKeys[5], '__', 'stringKeys[5] === "__"'); + assert.sameValue(stringKeys[6], 'a', 'stringKeys[6] === "a"'); + assert.sameValue(stringKeys[7], 'aa', 'stringKeys[7] === "aa"'); + assert.sameValue(stringKeys[8], 'az', 'stringKeys[8] === "az"'); + assert.sameValue(stringKeys[9], 'default', 'stringKeys[9] === "default"'); + assert.sameValue(stringKeys[10], 'z', 'stringKeys[10] === "z"'); + assert.sameValue(stringKeys[11], 'za', 'stringKeys[11] === "za"'); + assert.sameValue(stringKeys[12], 'zz', 'stringKeys[12] === "zz"'); + assert.sameValue(stringKeys[13], '\u03bb', 'stringKeys[13] === "\u03bb"'); + assert.sameValue(stringKeys[14], '\u03bc', 'stringKeys[14] === "\u03bc"'); + assert.sameValue(stringKeys[15], '\u03c0', 'stringKeys[15] === "\u03c0"'); + + var allKeys = Reflect.ownKeys(ns); + assert( + allKeys.length >= 17, + 'at least as many keys as defined by the module and the specification' + ); + assert.sameValue(allKeys[0], '$', 'allKeys[0] === "$"'); + assert.sameValue(allKeys[1], '$$', 'allKeys[1] === "$$"'); + assert.sameValue(allKeys[2], 'A', 'allKeys[2] === "A"'); + assert.sameValue(allKeys[3], 'Z', 'allKeys[3] === "Z"'); + assert.sameValue(allKeys[4], '_', 'allKeys[4] === "_"'); + assert.sameValue(allKeys[5], '__', 'allKeys[5] === "__"'); + assert.sameValue(allKeys[6], 'a', 'allKeys[6] === "a"'); + assert.sameValue(allKeys[7], 'aa', 'allKeys[7] === "aa"'); + assert.sameValue(allKeys[8], 'az', 'allKeys[8] === "az"'); + assert.sameValue(allKeys[9], 'default', 'allKeys[9] === "default"'); + assert.sameValue(allKeys[10], 'z', 'allKeys[10] === "z"'); + assert.sameValue(allKeys[11], 'za', 'allKeys[11] === "za"'); + assert.sameValue(allKeys[12], 'zz', 'allKeys[12] === "zz"'); + assert.sameValue(allKeys[13], '\u03bb', 'allKeys[13] === "\u03bb"'); + assert.sameValue(allKeys[14], '\u03bc', 'allKeys[14] === "\u03bc"'); + assert.sameValue(allKeys[15], '\u03c0', 'allKeys[15] === "\u03c0"'); + assert( + allKeys.indexOf(Symbol.toStringTag) > 15, + 'keys array includes Symbol.toStringTag' + ); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-prevent-extensions-object.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-prevent-extensions-object.js new file mode 100644 index 0000000000000000000000000000000000000000..0210353312174da98fe402f4e4ac8974af07ef3b --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-prevent-extensions-object.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-prevent-extensions-object.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[PreventExtensions]] internal method returns `true` (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +import('./empty_FIXTURE.js').then(ns => { + + // This invocation should not throw an exception + Object.preventExtensions(ns); + + assert.sameValue(Reflect.preventExtensions(ns), true); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-prevent-extensions-reflect.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-prevent-extensions-reflect.js new file mode 100644 index 0000000000000000000000000000000000000000..8860abb4a3e0cc7fd3077773a69c08fd082dfa56 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-prevent-extensions-reflect.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-prevent-extensions-reflect.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[PreventExtensions]] internal method returns `true` (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +import('./empty_FIXTURE.js').then(ns => { + + assert.sameValue(Reflect.preventExtensions(ns), true); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-prop-descs.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-prop-descs.js new file mode 100644 index 0000000000000000000000000000000000000000..dbd285644d60e6120b746044bb08f33435dc137e --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-prop-descs.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-prop-descs.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: imported object properties descriptors (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + // propertyHelper.js is not appropriate for this test because it assumes that + // the object exposes the ordinary object's implementation of [[Get]], [[Set]], +// [[Delete]], and [[OwnPropertyKeys]], which the module namespace exotic +// object does not. +var desc = Object.getOwnPropertyDescriptor(ns, 'default'); + +assert.sameValue(desc.value, 42, 'default: value is 42'); +assert.sameValue(desc.enumerable, true, 'default: is enumerable'); +assert.sameValue(desc.writable, true, 'default: is writable'); +assert.sameValue(desc.configurable, false, 'default: is non-configurable'); + +desc = Object.getOwnPropertyDescriptor(ns, 'local1'); + +assert.sameValue(desc.value, 'Test262', 'local1: value is "Test262"'); +assert.sameValue(desc.enumerable, true, 'local1: is enumerable'); +assert.sameValue(desc.writable, true, 'local1: is writable'); +assert.sameValue(desc.configurable, false, 'local1: is non-configurable'); + +desc = Object.getOwnPropertyDescriptor(ns, 'renamed'); + +assert.sameValue(desc.value, 'TC39', 'renamed: value is TC39"'); +assert.sameValue(desc.enumerable, true, 'renamed: is enumerable'); +assert.sameValue(desc.writable, true, 'renamed: is writable'); +assert.sameValue(desc.configurable, false, 'renamed: is non-configurable'); + +desc = Object.getOwnPropertyDescriptor(ns, 'indirect'); + +assert.sameValue(desc.value, 'Test262', 'indirect: value is Test262"'); +assert.sameValue(desc.enumerable, true, 'indirect: is enumerable'); +assert.sameValue(desc.writable, true, 'indirect: is writable'); +assert.sameValue(desc.configurable, false, 'indirect: is non-configurable'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-prototype.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-prototype.js new file mode 100644 index 0000000000000000000000000000000000000000..5af5a859d36f19a9ed8677dd2ea03d83e6556030 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-prototype.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-prototype.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Module namespace object prototype is null (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(ns instanceof Object, false); + assert.sameValue(Object.getPrototypeOf(ns), null, 'prototype is null'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-set-no-strict.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-no-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..759385ffed4f04d034cdea56a0560e2de2f6cf1a --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-no-strict.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-no-strict.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[Set]] internal method consistently returns `false`, No Strict Mode (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, noStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. Return false. + +---*/ +var sym = Symbol('test262'); + + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(Reflect.set(ns, 'local1'), false, 'Reflect.set: local1'); + assert.sameValue(ns.local1 = null, null, 'AssignmentExpression: local1'); + + assert.sameValue(Reflect.set(ns, 'local2'), false, 'Reflect.set: local2'); + assert.sameValue(ns.local2 = null, null, 'AssignmentExpression: local2'); + + assert.sameValue(Reflect.set(ns, 'renamed'), false, 'Reflect.set: renamed'); + assert.sameValue(ns.renamed = null, null, 'AssignmentExpression: renamed'); + + assert.sameValue(Reflect.set(ns, 'indirect'), false, 'Reflect.set: indirect'); + assert.sameValue(ns.indirect = null, null, 'AssignmentExpression: indirect'); + + assert.sameValue(Reflect.set(ns, 'default'), false, 'Reflect.set: default'); + assert.sameValue(ns.default = null, null, 'AssignmentExpression: default'); + + assert.sameValue( + Reflect.set(ns, Symbol.toStringTag, null), + false, + 'Reflect.set: Symbol.toStringTag' + ); + assert.sameValue(ns[Symbol.toStringTag] = null, null, 'AssignmentExpression: Symbol.toStringTag'); + + assert.sameValue(Reflect.set(ns, sym), false, 'Reflect.set: sym'); + assert.sameValue(ns[sym] = null, null, 'AssignmentExpression: sym'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-set-prototype-of-null.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-prototype-of-null.js new file mode 100644 index 0000000000000000000000000000000000000000..95e9e8b15ae700eefe921c336eaca2f937372ddc --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-prototype-of-null.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-prototype-of-null.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[SetPrototypeOf]] internal method returns `true` if passed `null` (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +import('./empty_FIXTURE.js').then(ns => { + + assert.sameValue(typeof Object.setPrototypeOf, 'function'); + assert.sameValue(ns, Object.setPrototypeOf(ns, null)); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-set-prototype-of.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-prototype-of.js new file mode 100644 index 0000000000000000000000000000000000000000..9636c173e8629844cd597856a8120cf6002e1b49 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-prototype-of.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-prototype-of.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[SetPrototypeOf]] internal method returns `false` (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + var newProto = {}; + + assert.sameValue(typeof Object.setPrototypeOf, 'function'); + + assert.throws(TypeError, function() { + Object.setPrototypeOf(ns, newProto); + }); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-set-same-values-no-strict.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-same-values-no-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..63d1246935c44900824cc02e37b9bbf9e4f6cb03 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-same-values-no-strict.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-same-values-no-strict.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[Set]] internal method consistently returns `false` even setting the same value - No Strict Mode (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, noStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. Return false. + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(Reflect.set(ns, 'local1', 'Test262'), false, 'Reflect.set: local1'); + assert.sameValue(ns.local1 = 'Test262', 'Test262', 'AssignmentExpression: local1'); + + assert.sameValue(Reflect.set(ns, 'renamed', 'TC39'), false, 'Reflect.set: renamed'); + assert.sameValue(ns.renamed = 'TC39', 'TC39', 'AssignmentExpression: renamed'); + + assert.sameValue(Reflect.set(ns, 'indirect', 'Test262'), false, 'Reflect.set: indirect'); + assert.sameValue(ns.indirect = 'Test262', 'Test262', 'AssignmentExpression: indirect'); + + assert.sameValue(Reflect.set(ns, 'default', 42), false, 'Reflect.set: default'); + assert.sameValue(ns.default = 42, 42, 'AssignmentExpression: default'); + + assert.sameValue( + Reflect.set(ns, Symbol.toStringTag, ns[Symbol.toStringTag]), + false, + 'Reflect.set: Symbol.toStringTag' + ); + assert.sameValue(ns[Symbol.toStringTag] = ns[Symbol.toStringTag], 'Module', 'AssignmentExpression: Symbol.toStringTag'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-set-same-values-strict.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-same-values-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..edbc50d19ba7d8bc0f5cf97a8dd16ba4f4680db0 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-same-values-strict.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-same-values-strict.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[Set]] internal method consistently returns `false` even setting the same value - Strict Mode (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, onlyStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. Return false. + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(Reflect.set(ns, 'local1', 'Test262'), false, 'Reflect.set: local1'); + assert.throws(TypeError, function() { + ns.local1 = 'Test262'; + }, 'AssignmentExpression: local1'); + + assert.sameValue(Reflect.set(ns, 'renamed', 'TC39'), false, 'Reflect.set: renamed'); + assert.throws(TypeError, function() { + ns.renamed = 'TC39'; + }, 'AssignmentExpression: renamed'); + + assert.sameValue(Reflect.set(ns, 'indirect', 'Test262'), false, 'Reflect.set: indirect'); + assert.throws(TypeError, function() { + ns.indirect = 'Test262'; + }, 'AssignmentExpression: indirect'); + + assert.sameValue(Reflect.set(ns, 'default', 42), false, 'Reflect.set: default'); + assert.throws(TypeError, function() { + ns.default = 42; + }, 'AssignmentExpression: default'); + + assert.sameValue( + Reflect.set(ns, Symbol.toStringTag, ns[Symbol.toStringTag]), + false, + 'Reflect.set: Symbol.toStringTag' + ); + assert.throws(TypeError, function() { + ns[Symbol.toStringTag] = ns[Symbol.toStringTag]; + }, 'AssignmentExpression: Symbol.toStringTag'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-set-strict.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..4518fc4d3ef455db464665e2cf7fc5a72943ebe3 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-strict.js @@ -0,0 +1,120 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-strict.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[Set]] internal method consistently returns `false`, Strict Mode (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, onlyStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. Return false. + +---*/ +var sym = Symbol('test262'); + + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(Reflect.set(ns, 'local1'), false, 'Reflect.set: local1'); + assert.throws(TypeError, function() { + ns.local1 = null; + }, 'AssignmentExpression: local1'); + + assert.sameValue(Reflect.set(ns, 'local2'), false, 'Reflect.set: local2'); + assert.throws(TypeError, function() { + ns.local2 = null; + }, 'AssignmentExpression: local2'); + + assert.sameValue(Reflect.set(ns, 'renamed'), false, 'Reflect.set: renamed'); + assert.throws(TypeError, function() { + ns.renamed = null; + }, 'AssignmentExpression: renamed'); + + assert.sameValue(Reflect.set(ns, 'indirect'), false, 'Reflect.set: indirect'); + assert.throws(TypeError, function() { + ns.indirect = null; + }, 'AssignmentExpression: indirect'); + + assert.sameValue(Reflect.set(ns, 'default'), false, 'Reflect.set: default'); + assert.throws(TypeError, function() { + ns.default = null; + }, 'AssignmentExpression: default'); + + assert.sameValue( + Reflect.set(ns, Symbol.toStringTag, null), + false, + 'Reflect.set: Symbol.toStringTag' + ); + assert.throws(TypeError, function() { + ns[Symbol.toStringTag] = null; + }, 'AssignmentExpression: Symbol.toStringTag'); + + assert.sameValue(Reflect.set(ns, sym), false, 'Reflect.set: sym'); + assert.throws(TypeError, function() { + ns[sym] = null; + }, 'AssignmentExpression: sym'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/returns-promise.js b/test/language/module-code/dynamic-import/returns-promise.js new file mode 100644 index 0000000000000000000000000000000000000000..e44f6e24eb3b6a3a962898bed455b96f9d8e64dc --- /dev/null +++ b/test/language/module-code/dynamic-import/returns-promise.js @@ -0,0 +1,53 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + ImportCall returns a promise +esid: sec-import-call-runtime-semantics-evaluation +info: | + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. +features: [dynamic-import] +includes: [fnGlobalObject.js] +---*/ + +const originalPromise = Promise; + +fnGlobalObject().Promise = function() { + throw "This should not be called"; +}; + +const p = import('./dynamic-import-module_FIXTURE.js'); + +assert.sameValue(p.constructor, originalPromise, 'constructor is %Promise%'); +assert.sameValue(Object.getPrototypeOf(p), originalPromise.prototype, 'prototype is %PromisePrototype%'); +assert.sameValue(p.then, originalPromise.prototype.then, 'preserves the original `then` method'); +assert.sameValue(p.catch, originalPromise.prototype.catch, 'preserves the original `catch` method'); +assert.sameValue(p.finally, originalPromise.prototype.finally, 'preserves the original `finally` method'); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(p, 'then'), false, + 'returned promise has no own property then' +); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(p, 'catch'), false, + 'returned promise has no own property catch' +); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(p, 'finally'), false, + 'returned promise has no own property finally' +); diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-arrow-assignment-expression-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-arrow-assignment-expression-script-code-valid.js index c5654cd220ed217ebd15905f56603a0ba4ea4eb5..c2f9ad358fadf086bd89df47e42cd055406149bf 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-arrow-assignment-expression-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-arrow-assignment-expression-script-code-valid.js @@ -26,4 +26,4 @@ info: | var smoosh; function smoosh() {} -let f = () => import('./script-code-valid.js'); +let f = () => import('./empty_FIXTURE.js'); diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-arrow-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-arrow-script-code-valid.js index 590fff106f11f7420c7d250f1c75fafc2744bc3a..d0b96c3678d40424300961254abab1cba840ab63 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-arrow-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-arrow-script-code-valid.js @@ -27,5 +27,5 @@ var smoosh; function smoosh() {} let f = () => { - import('./script-code-valid.js'); + import('./empty_FIXTURE.js'); }; diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-await-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-await-script-code-valid.js index 90849fabfe36863028cc816da16777c3e39294e9..111ba41252ed189bed1c9a8d02ea24f1ce28537c 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-await-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-await-script-code-valid.js @@ -27,5 +27,5 @@ var smoosh; function smoosh() {} async function f() { - await import('./script-code-valid.js'); + await import('./empty_FIXTURE.js'); } diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-return-await-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-return-await-script-code-valid.js index f383065913465092cae33b5087905c9dda67a470..94225d612051d4d4126e57b51468c8df85ccd116 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-return-await-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-return-await-script-code-valid.js @@ -27,6 +27,6 @@ var smoosh; function smoosh() {} async function f() { - return await import('./script-code-valid.js'); + return await import('./empty_FIXTURE.js'); } diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-script-code-valid.js index e00d0a7ffdbee48c09c9720e89bac53769e3642d..9b28f3564e95a193cdc8e8ce129bb204f6c757e1 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-script-code-valid.js @@ -27,6 +27,6 @@ var smoosh; function smoosh() {} async function f() { - import('./script-code-valid.js'); + import('./empty_FIXTURE.js'); } diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-block-labeled-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-block-labeled-script-code-valid.js index 0d36b64b70dfa0ac40d4c526a77ab500fe23df04..cce923e15e57cf37b55e7973d00cc8e0794ac69c 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-block-labeled-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-block-labeled-script-code-valid.js @@ -27,5 +27,5 @@ var smoosh; function smoosh() {} label: { - import('./script-code-valid.js'); + import('./empty_FIXTURE.js'); }; diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-block-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-block-script-code-valid.js index f66e994bd06829810b0b4e055b3e763e8a34d2f7..5cad7f4698115bb91f38c3f45501c6012aab6959 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-block-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-block-script-code-valid.js @@ -27,5 +27,5 @@ var smoosh; function smoosh() {} { - import('./script-code-valid.js'); + import('./empty_FIXTURE.js'); }; diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-do-while-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-do-while-script-code-valid.js index 1b86097b58448ff3c7753d407d73671eebfddde8..e667c594e0eefa59014b537c5ca00828574228c8 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-do-while-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-do-while-script-code-valid.js @@ -27,5 +27,5 @@ var smoosh; function smoosh() {} do { - import('./script-code-valid.js'); + import('./empty_FIXTURE.js'); } while (false); diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-else-braceless-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-else-braceless-script-code-valid.js index 4426fcca22c2f01099eeb0b30d6f7fdebb8bf3bf..d71f70bef950bbe052951ef5d259c9760feb414a 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-else-braceless-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-else-braceless-script-code-valid.js @@ -28,4 +28,4 @@ var smoosh; function smoosh() {} if (false) { -} else import('./script-code-valid.js'); +} else import('./empty_FIXTURE.js'); diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-else-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-else-script-code-valid.js index 7ec91b881a30c0e613df73ee46c0f614de8cc54d..b621c6ff78df0729f94a6ced5fef92dae5dce075 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-else-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-else-script-code-valid.js @@ -29,5 +29,5 @@ var smoosh; function smoosh() {} if (false) { } else { - import('./script-code-valid.js'); + import('./empty_FIXTURE.js'); } diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-function-return-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-function-return-script-code-valid.js index 5a871fa54affccb9904dfa1c223a67a2166af329..0719c15fcabd287b069138cf176ec07e86c152e3 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-function-return-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-function-return-script-code-valid.js @@ -27,5 +27,5 @@ var smoosh; function smoosh() {} function fn() { - return import('./script-code-valid.js'); + return import('./empty_FIXTURE.js'); } diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-function-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-function-script-code-valid.js index 68f127e3e1cca5086619bc951bcbba3a0ba810ce..cdf6fc0555fd186444b95604093a087b0f781a65 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-function-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-function-script-code-valid.js @@ -27,5 +27,5 @@ var smoosh; function smoosh() {} function fn() { - import('./script-code-valid.js'); + import('./empty_FIXTURE.js'); } diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-if-braceless-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-if-braceless-script-code-valid.js index e449237b2bda8b69acfe6e6a26150343a1d6c026..b01c66b8d9c22b460fb4c91339e3d4969a8cfb2c 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-if-braceless-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-if-braceless-script-code-valid.js @@ -26,4 +26,4 @@ info: | var smoosh; function smoosh() {} -if (true) import('./script-code-valid.js'); +if (true) import('./empty_FIXTURE.js'); diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-if-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-if-script-code-valid.js index f2b1eb9c25604ec66ef58e3e99feb131fb8ecc36..89fa4f15eb37ed963435440e8aba6e939d51112c 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-if-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-if-script-code-valid.js @@ -27,5 +27,5 @@ var smoosh; function smoosh() {} if (true) { - import('./script-code-valid.js'); + import('./empty_FIXTURE.js'); } diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-while-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-while-script-code-valid.js index b196e203ea4a0deda6c4e8bd38e6e0199c3605ca..48a0a3cb0e694fafe78c9b19bf0a0cb47ae05de1 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-while-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-while-script-code-valid.js @@ -29,5 +29,5 @@ var smoosh; function smoosh() {} let x = 0; while (!x) { x++; - import('./script-code-valid.js'); + import('./empty_FIXTURE.js'); }; diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-with-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-with-script-code-valid.js index b46979d5ece4dd73928d0143dc618b20f8497531..7334f8870994d9a8e0def64e36439304a44b2654 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-with-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-with-script-code-valid.js @@ -27,5 +27,5 @@ var smoosh; function smoosh() {} with ({}) { - import('./script-code-valid.js'); + import('./empty_FIXTURE.js'); } diff --git a/test/language/module-code/dynamic-import/syntax/valid/top-level-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/top-level-script-code-valid.js index 3aa54554ba511e998e9dacecae48ce53688ee0af..c04af7884fd62039d1a70fedc6cf4b6c1957729e 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/top-level-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/top-level-script-code-valid.js @@ -16,4 +16,4 @@ info: | var smoosh; function smoosh() {} -import('./script-code-valid.js'); +import('./empty_FIXTURE.js'); diff --git a/test/language/module-code/dynamic-import/usage/module-code_FIXTURE.js b/test/language/module-code/dynamic-import/usage/module-code_FIXTURE.js new file mode 100644 index 0000000000000000000000000000000000000000..96b0503d9582a68a13f5ac77ee63279dc424fd65 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/module-code_FIXTURE.js @@ -0,0 +1,8 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +const x = 'Test262'; +const y = 42; + +export default y; +export { x, y as z }; diff --git a/test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000000000000000000000000000000000..09c4d51abce9c398c648d11717c73c752f490fe5 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-arrow-assign-expr.template +/*--- +description: import() from a ascript code can load a file with module code (nested arrow) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +let f = () => import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + +}); + + +f().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-returns-thenable.js similarity index 90% rename from test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-returns-thenable.js index 463c475f53724b019709e4856bfc36641bc327e9..b72f8acdf6fe24296f9d0aab409f07dbfe82af6f 100644 --- a/test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-arrow-assign-expr.template /*--- -description: Dynamic import() returns a Promise object. (nested arrow) +description: Dynamic import() returns a thenable object. (nested arrow) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-specifier-tostring.js new file mode 100644 index 0000000000000000000000000000000000000000..3b51623c57a54572b99736896d3332a5f9ece312 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-specifier-tostring.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-arrow-assign-expr.template +/*--- +description: ToString value of specifier (nested arrow) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +let f = () => import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + +}); + + +f().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-arrow-import-then-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-arrow-import-then-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000000000000000000000000000000000..25bffd31256a7d25e44af199764795870c8c1f5a --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-arrow-import-then-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-arrow.template +/*--- +description: import() from a ascript code can load a file with module code (nested arrow) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +let f = () => { + return import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +}; + +f(); + diff --git a/test/language/module-code/dynamic-import/usage/nested-arrow-import-then-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-arrow-import-then-returns-thenable.js similarity index 90% rename from test/language/module-code/dynamic-import/usage/nested-arrow-import-then-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-arrow-import-then-returns-thenable.js index 0a5edbe9bccf23438a17ab545d31150c827061cb..b726b0af63c90b9ab7601d27ccb43f0de6304ea0 100644 --- a/test/language/module-code/dynamic-import/usage/nested-arrow-import-then-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-arrow-import-then-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-arrow.template /*--- -description: Dynamic import() returns a Promise object. (nested arrow) +description: Dynamic import() returns a thenable object. (nested arrow) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-arrow-import-then-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-arrow-import-then-specifier-tostring.js new file mode 100644 index 0000000000000000000000000000000000000000..442d5cf63da57c9e53f4eb705dc7ac94486c787e --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-arrow-import-then-specifier-tostring.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-arrow.template +/*--- +description: ToString value of specifier (nested arrow) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +let f = () => { + return import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +}; + +f(); + diff --git a/test/language/module-code/dynamic-import/usage/nested-async-function-await-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-async-function-await-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000000000000000000000000000000000..49578b592815fd46b8ee5cdb25cfc35e146ac980 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-function-await-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-async-function-await.template +/*--- +description: import() from a ascript code can load a file with module code (nested in async function, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +async function f() { + await import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }); +} + +f().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-function-await-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-async-function-await-returns-thenable.js similarity index 88% rename from test/language/module-code/dynamic-import/usage/nested-async-function-await-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-async-function-await-returns-thenable.js index 065feb806fa2ed1f4034ebb27354298a9c7ce58e..24eb32af4155aa1a39e6184a89fa48450c7cf06b 100644 --- a/test/language/module-code/dynamic-import/usage/nested-async-function-await-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-async-function-await-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-async-function-await.template /*--- -description: Dynamic import() returns a Promise object. (nested in async function, awaited) +description: Dynamic import() returns a thenable object. (nested in async function, awaited) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-async-function-await-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-async-function-await-specifier-tostring.js new file mode 100644 index 0000000000000000000000000000000000000000..6906ae7d56366cb0dd474ff1380f05f64777b8a0 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-function-await-specifier-tostring.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-async-function-await.template +/*--- +description: ToString value of specifier (nested in async function, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +async function f() { + await import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }); +} + +f().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-function-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-async-function-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000000000000000000000000000000000..71148fc8f78a9731887fac55d242a1295c7118d9 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-function-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-async-function.template +/*--- +description: import() from a ascript code can load a file with module code (nested in async function) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +async function f() { + import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +} + +f(); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-function-return-await-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-async-function-return-await-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000000000000000000000000000000000..173933e313c258c8bb78cec7e5e2ac2fea109a6b --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-function-return-await-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-async-function-return-await.template +/*--- +description: import() from a ascript code can load a file with module code (nested in async function, returns awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +async function f() { + return await import('./module-code_FIXTURE.js'); +} + +f().then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-function-return-await-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-async-function-return-await-returns-thenable.js similarity index 88% rename from test/language/module-code/dynamic-import/usage/nested-async-function-return-await-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-async-function-return-await-returns-thenable.js index 135a98225e975281d617ec4033a0f1fb9093a75b..0541c60034161e0d3772deb364503d0c68356fc5 100644 --- a/test/language/module-code/dynamic-import/usage/nested-async-function-return-await-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-async-function-return-await-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-async-function-return-await.template /*--- -description: Dynamic import() returns a Promise object. (nested in async function, returns awaited) +description: Dynamic import() returns a thenable object. (nested in async function, returns awaited) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-async-function-return-await-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-async-function-return-await-specifier-tostring.js new file mode 100644 index 0000000000000000000000000000000000000000..260d2b96bac606eeca8adb1fbdc46acbef07dc18 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-function-return-await-specifier-tostring.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-async-function-return-await.template +/*--- +description: ToString value of specifier (nested in async function, returns awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +async function f() { + return await import(obj); +} + +f().then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-function-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-async-function-returns-thenable.js similarity index 89% rename from test/language/module-code/dynamic-import/usage/nested-async-function-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-async-function-returns-thenable.js index 435b3e0d3eb044510e3070e31f343716ef6fa31d..943efb3acd4b3c5148ee44bc4ad89f53da7f1dbb 100644 --- a/test/language/module-code/dynamic-import/usage/nested-async-function-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-async-function-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-async-function.template /*--- -description: Dynamic import() returns a Promise object. (nested in async function) +description: Dynamic import() returns a thenable object. (nested in async function) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-async-function-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-async-function-specifier-tostring.js new file mode 100644 index 0000000000000000000000000000000000000000..8ee53673dbc987698798fa6d38fcb1a9dba5ad7a --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-function-specifier-tostring.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-async-function.template +/*--- +description: ToString value of specifier (nested in async function) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +async function f() { + import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +} + +f(); diff --git a/test/language/module-code/dynamic-import/usage/nested-block-import-then-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-block-import-then-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000000000000000000000000000000000..73047f13b4957fedc733cf58afadcb03b98d9bf7 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-block-import-then-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-block.template +/*--- +description: import() from a ascript code can load a file with module code (nested block) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +{ + import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +}; diff --git a/test/language/module-code/dynamic-import/usage/nested-block-import-then-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-block-import-then-returns-thenable.js similarity index 90% rename from test/language/module-code/dynamic-import/usage/nested-block-import-then-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-block-import-then-returns-thenable.js index 997722f9668ee1ebd35ca7b83f83f1bf843dae55..a5340ac60c210ccfaf279350838f54ff49b16406 100644 --- a/test/language/module-code/dynamic-import/usage/nested-block-import-then-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-block-import-then-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-block.template /*--- -description: Dynamic import() returns a Promise object. (nested block) +description: Dynamic import() returns a thenable object. (nested block) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-block-import-then-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-block-import-then-specifier-tostring.js new file mode 100644 index 0000000000000000000000000000000000000000..73d423848635fd966ffc8998a569b70f20c873c1 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-block-import-then-specifier-tostring.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-block.template +/*--- +description: ToString value of specifier (nested block) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +{ + import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +}; diff --git a/test/language/module-code/dynamic-import/usage/nested-do-while-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-do-while-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000000000000000000000000000000000..0d03d24facf791a98ad10b1ff9dd86d0fdcdcd3d --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-do-while-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-do-while.template +/*--- +description: import() from a ascript code can load a file with module code (nested do while syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +do { + import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +} while (false); diff --git a/test/language/module-code/dynamic-import/usage/nested-do-while-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-do-while-returns-thenable.js similarity index 89% rename from test/language/module-code/dynamic-import/usage/nested-do-while-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-do-while-returns-thenable.js index 1907481f2c7c9c4f6b71720e75f5584242c33c92..7cd332dd3cf84631494fb2af59293de74e0915a1 100644 --- a/test/language/module-code/dynamic-import/usage/nested-do-while-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-do-while-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-do-while.template /*--- -description: Dynamic import() returns a Promise object. (nested do while syntax) +description: Dynamic import() returns a thenable object. (nested do while syntax) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-do-while-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-do-while-specifier-tostring.js new file mode 100644 index 0000000000000000000000000000000000000000..e352bbdffaa075462161ba9704bc57da046dd0b4 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-do-while-specifier-tostring.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-do-while.template +/*--- +description: ToString value of specifier (nested do while syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +do { + import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +} while (false); diff --git a/test/language/module-code/dynamic-import/usage/nested-else-import-then-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-else-import-then-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000000000000000000000000000000000..fd0ba3df2c8bc75bfee0e65ea9065b6df9d04972 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-else-import-then-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-else.template +/*--- +description: import() from a ascript code can load a file with module code (nested else) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +if (false) { + +} else { + import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +} diff --git a/test/language/module-code/dynamic-import/usage/nested-else-import-then-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-else-import-then-returns-thenable.js similarity index 90% rename from test/language/module-code/dynamic-import/usage/nested-else-import-then-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-else-import-then-returns-thenable.js index afde7ff219eaa66bea140f856f66813b2858e637..b3d67e51e90989fe0f0e980ca7374065e8f182d0 100644 --- a/test/language/module-code/dynamic-import/usage/nested-else-import-then-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-else-import-then-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-else.template /*--- -description: Dynamic import() returns a Promise object. (nested else) +description: Dynamic import() returns a thenable object. (nested else) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-else-import-then-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-else-import-then-specifier-tostring.js new file mode 100644 index 0000000000000000000000000000000000000000..e30494dbd925f2decee20947b0ddd655f63910c5 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-else-import-then-specifier-tostring.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-else.template +/*--- +description: ToString value of specifier (nested else) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +if (false) { + +} else { + import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +} diff --git a/test/language/module-code/dynamic-import/usage/nested-function-import-then-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-function-import-then-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000000000000000000000000000000000..1c5d97e5254589af90cc2d6d7ae4511a443bdea3 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-function-import-then-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-function.template +/*--- +description: import() from a ascript code can load a file with module code (nested function) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +function f() { + import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +} +f(); diff --git a/test/language/module-code/dynamic-import/usage/nested-function-import-then-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-function-import-then-returns-thenable.js similarity index 90% rename from test/language/module-code/dynamic-import/usage/nested-function-import-then-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-function-import-then-returns-thenable.js index ab2ff9bfa3be3c3ceb2c9e59109e62a4a0a9770f..53883c18667be8169aa7577f1195d6053462f256 100644 --- a/test/language/module-code/dynamic-import/usage/nested-function-import-then-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-function-import-then-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-function.template /*--- -description: Dynamic import() returns a Promise object. (nested function) +description: Dynamic import() returns a thenable object. (nested function) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-function-import-then-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-function-import-then-specifier-tostring.js new file mode 100644 index 0000000000000000000000000000000000000000..49178a51de8053f3432e7df5c769fe3dd4d20f6a --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-function-import-then-specifier-tostring.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-function.template +/*--- +description: ToString value of specifier (nested function) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +function f() { + import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +} +f(); diff --git a/test/language/module-code/dynamic-import/usage/nested-if-braceless-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-if-braceless-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000000000000000000000000000000000..e41cca756593216e86774302023150f2fdd25cf3 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-if-braceless-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-if-braceless.template +/*--- +description: import() from a ascript code can load a file with module code (nested if syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +if (true) import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-if-braceless-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-if-braceless-returns-thenable.js similarity index 89% rename from test/language/module-code/dynamic-import/usage/nested-if-braceless-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-if-braceless-returns-thenable.js index 37710f3aadb0cd19abfefcdf278f0f821819b7a3..1701a0f191a992ad43b25ffa4d0629458fdf427d 100644 --- a/test/language/module-code/dynamic-import/usage/nested-if-braceless-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-if-braceless-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-if-braceless.template /*--- -description: Dynamic import() returns a Promise object. (nested if syntax) +description: Dynamic import() returns a thenable object. (nested if syntax) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-if-braceless-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-if-braceless-specifier-tostring.js new file mode 100644 index 0000000000000000000000000000000000000000..b41dd6402936454dd34bd61a96ce419c107b3c94 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-if-braceless-specifier-tostring.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-if-braceless.template +/*--- +description: ToString value of specifier (nested if syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +if (true) import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-if-import-then-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-if-import-then-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000000000000000000000000000000000..2c0d6ca1cde98f3140363ea07f964969404d9723 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-if-import-then-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-if.template +/*--- +description: import() from a ascript code can load a file with module code (nested if) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +if (true) { + import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +} diff --git a/test/language/module-code/dynamic-import/usage/nested-if-import-then-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-if-import-then-returns-thenable.js similarity index 90% rename from test/language/module-code/dynamic-import/usage/nested-if-import-then-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-if-import-then-returns-thenable.js index 57f9e7dc83a69a7a2a5f2b738859ab379f739e87..e16fce36373fc0a19c97910bd6a82f060f6d4c72 100644 --- a/test/language/module-code/dynamic-import/usage/nested-if-import-then-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-if-import-then-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-if.template /*--- -description: Dynamic import() returns a Promise object. (nested if) +description: Dynamic import() returns a thenable object. (nested if) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-if-import-then-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-if-import-then-specifier-tostring.js new file mode 100644 index 0000000000000000000000000000000000000000..44e2a5cb53ea1396d604309777e22a45ff6fbe55 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-if-import-then-specifier-tostring.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-if.template +/*--- +description: ToString value of specifier (nested if) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +if (true) { + import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +} diff --git a/test/language/module-code/dynamic-import/usage/nested-while-import-then-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-while-import-then-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000000000000000000000000000000000..0fb62b6e7f180b2704e8c31034e4cdd2fa8baa29 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-while-import-then-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-while.template +/*--- +description: import() from a ascript code can load a file with module code (nested while) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +let x = 0; +while (!x) { + x++; + import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +}; diff --git a/test/language/module-code/dynamic-import/usage/nested-while-import-then-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-while-import-then-returns-thenable.js similarity index 90% rename from test/language/module-code/dynamic-import/usage/nested-while-import-then-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-while-import-then-returns-thenable.js index f4bef3e87ba6de20c56a7be2dc867d45b39fb916..2d6ae02f6b0da775c8e055eb1f3f0614e6e34817 100644 --- a/test/language/module-code/dynamic-import/usage/nested-while-import-then-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-while-import-then-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-while.template /*--- -description: Dynamic import() returns a Promise object. (nested while) +description: Dynamic import() returns a thenable object. (nested while) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-while-import-then-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-while-import-then-specifier-tostring.js new file mode 100644 index 0000000000000000000000000000000000000000..749504ffc1e2c6371f0cf41f134dfbf7ff4299e8 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-while-import-then-specifier-tostring.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-while.template +/*--- +description: ToString value of specifier (nested while) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +let x = 0; +while (!x) { + x++; + import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +}; diff --git a/test/language/module-code/dynamic-import/usage/nested-with-import-then-eval-gtbndng-indirect-update-dflt.js b/test/language/module-code/dynamic-import/usage/nested-with-import-then-eval-gtbndng-indirect-update-dflt.js deleted file mode 100644 index c8232adb174dd330d35422d8895e1936526e2297..0000000000000000000000000000000000000000 --- a/test/language/module-code/dynamic-import/usage/nested-with-import-then-eval-gtbndng-indirect-update-dflt.js +++ /dev/null @@ -1,44 +0,0 @@ -// This file was procedurally generated from the following sources: -// - src/dynamic-import/eval-gtbndng-indirect-update-dflt.case -// - src/dynamic-import/default/nested-with.template -/*--- -description: Modifications to default binding that occur after dependency has been evaluated are reflected in local binding (nested with) -esid: sec-import-call-runtime-semantics-evaluation -features: [dynamic-import] -flags: [generated, async, noStrict] -info: | - ImportCall : - import( AssignmentExpression ) - - 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). - 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). - 3. Let argRef be the result of evaluating AssignmentExpression. - 4. Let specifier be ? GetValue(argRef). - 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). - 6. Let specifierString be ToString(specifier). - 7. IfAbruptRejectPromise(specifierString, promiseCapability). - 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). - 9. Return promiseCapability.[[Promise]]. - - - GetBindingValue (N, S) - - [...] - 3. If the binding for N is an indirect binding, then - a. Let M and N2 be the indirection values provided when this binding for - N was created. - b. Let targetEnv be M.[[Environment]]. - c. If targetEnv is undefined, throw a ReferenceError exception. - d. Let targetER be targetEnv's EnvironmentRecord. - e. Return ? targetER.GetBindingValue(N2, S). - ----*/ - -with ({}) { - import('./eval-gtbndng-indirect-update-dflt_FIXTURE.js').then(imported => { - - assert.sameValue(imported.default(), 1); - assert.sameValue(imported.default, 2); - - }).then($DONE, $DONE).catch($DONE); -} diff --git a/test/language/module-code/dynamic-import/usage/nested-with-import-then-eval-gtbndng-indirect-update.js b/test/language/module-code/dynamic-import/usage/nested-with-import-then-eval-gtbndng-indirect-update.js deleted file mode 100644 index d39cd5cfae154f07f8b7e2c772830746a2f6df13..0000000000000000000000000000000000000000 --- a/test/language/module-code/dynamic-import/usage/nested-with-import-then-eval-gtbndng-indirect-update.js +++ /dev/null @@ -1,52 +0,0 @@ -// This file was procedurally generated from the following sources: -// - src/dynamic-import/eval-gtbndng-indirect-update.case -// - src/dynamic-import/default/nested-with.template -/*--- -description: Modifications to named bindings that occur after dependency has been evaluated are reflected in local binding (nested with) -esid: sec-import-call-runtime-semantics-evaluation -features: [dynamic-import] -flags: [generated, async, noStrict] -includes: [fnGlobalObject.js] -info: | - ImportCall : - import( AssignmentExpression ) - - 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). - 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). - 3. Let argRef be the result of evaluating AssignmentExpression. - 4. Let specifier be ? GetValue(argRef). - 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). - 6. Let specifierString be ToString(specifier). - 7. IfAbruptRejectPromise(specifierString, promiseCapability). - 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). - 9. Return promiseCapability.[[Promise]]. - - - GetBindingValue (N, S) - - [...] - 3. If the binding for N is an indirect binding, then - a. Let M and N2 be the indirection values provided when this binding for - N was created. - b. Let targetEnv be M.[[Environment]]. - c. If targetEnv is undefined, throw a ReferenceError exception. - d. Let targetER be targetEnv's EnvironmentRecord. - e. Return ? targetER.GetBindingValue(N2, S). - ----*/ - -with ({}) { - import('./eval-gtbndng-indirect-update_FIXTURE.js').then(imported => { - - assert.sameValue(imported.x, 1); - - // This function is exposed on the global scope (instead of as an exported - // binding) in order to avoid possible false positives from assuming correct - // behavior of the semantics under test. - fnGlobalObject().test262update(); - - assert.sameValue(imported.x, 2); - - - }).then($DONE, $DONE).catch($DONE); -} diff --git a/test/language/module-code/dynamic-import/usage/nested-with-import-then-is-call-expression-square-brackets.js b/test/language/module-code/dynamic-import/usage/nested-with-import-then-is-call-expression-square-brackets.js deleted file mode 100644 index 18d95fe17a03710c9b404dae042b7b2b6c937b3b..0000000000000000000000000000000000000000 --- a/test/language/module-code/dynamic-import/usage/nested-with-import-then-is-call-expression-square-brackets.js +++ /dev/null @@ -1,31 +0,0 @@ -// This file was procedurally generated from the following sources: -// - src/dynamic-import/is-call-expression-square-brackets.case -// - src/dynamic-import/default/nested-with.template -/*--- -description: ImportCall is a CallExpression, it can be followed by square brackets (nested with) -esid: sec-import-call-runtime-semantics-evaluation -features: [dynamic-import] -flags: [generated, async, noStrict] -info: | - ImportCall : - import( AssignmentExpression ) - - 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). - 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). - 3. Let argRef be the result of evaluating AssignmentExpression. - 4. Let specifier be ? GetValue(argRef). - 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). - 6. Let specifierString be ToString(specifier). - 7. IfAbruptRejectPromise(specifierString, promiseCapability). - 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). - 9. Return promiseCapability.[[Promise]]. - ----*/ - -with ({}) { - import('./dynamic-import-module_FIXTURE.js')['then'](x => x).then(imported => { - - assert.sameValue(imported.x, 1); - - }).then($DONE, $DONE).catch($DONE); -} diff --git a/test/language/module-code/dynamic-import/usage/nested-with-import-then-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-with-import-then-returns-promise.js deleted file mode 100644 index 0b17dd7aeba79e0c5327e6d1b488e175506bb4f3..0000000000000000000000000000000000000000 --- a/test/language/module-code/dynamic-import/usage/nested-with-import-then-returns-promise.js +++ /dev/null @@ -1,31 +0,0 @@ -// This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case -// - src/dynamic-import/default/nested-with.template -/*--- -description: Dynamic import() returns a Promise object. (nested with) -esid: sec-import-call-runtime-semantics-evaluation -features: [dynamic-import] -flags: [generated, async, noStrict] -info: | - ImportCall : - import( AssignmentExpression ) - - 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). - 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). - 3. Let argRef be the result of evaluating AssignmentExpression. - 4. Let specifier be ? GetValue(argRef). - 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). - 6. Let specifierString be ToString(specifier). - 7. IfAbruptRejectPromise(specifierString, promiseCapability). - 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). - 9. Return promiseCapability.[[Promise]]. - ----*/ - -with ({}) { - import('./dynamic-import-module_FIXTURE.js').then(imported => { - - assert.sameValue(imported.x, 1); - - }).then($DONE, $DONE).catch($DONE); -} diff --git a/test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000000000000000000000000000000000..de78996dd46a85a085eff0765369c491f4713090 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-block-labeled.template +/*--- +description: import() from a ascript code can load a file with module code (nested block syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +label: { + import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +}; diff --git a/test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-returns-promise.js b/test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-returns-thenable.js similarity index 89% rename from test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-returns-promise.js rename to test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-returns-thenable.js index 877e77c22e6389ac939904e188fb49b447ab90da..9eae36c213f0bc2dca2ceb3f2246d199e8b71e94 100644 --- a/test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-block-labeled.template /*--- -description: Dynamic import() returns a Promise object. (nested block syntax) +description: Dynamic import() returns a thenable object. (nested block syntax) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-specifier-tostring.js new file mode 100644 index 0000000000000000000000000000000000000000..e784c53fc35af8aa5f1324d18c9dbd2db682519a --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-specifier-tostring.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-block-labeled.template +/*--- +description: ToString value of specifier (nested block syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +label: { + import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +}; diff --git a/test/language/module-code/dynamic-import/usage/top-level-import-then-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/top-level-import-then-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000000000000000000000000000000000..e8e6f7578beb548acf562536478df966f9eabc0f --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/top-level-import-then-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/top-level.template +/*--- +description: import() from a ascript code can load a file with module code (top level) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/top-level-import-then-returns-promise.js b/test/language/module-code/dynamic-import/usage/top-level-import-then-returns-thenable.js similarity index 90% rename from test/language/module-code/dynamic-import/usage/top-level-import-then-returns-promise.js rename to test/language/module-code/dynamic-import/usage/top-level-import-then-returns-thenable.js index 626bc97edaf199f7e2110e7883a61aff53a32c0c..ea980190d4aed159f44cbc3beb173f6e150f9872 100644 --- a/test/language/module-code/dynamic-import/usage/top-level-import-then-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/top-level-import-then-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/top-level.template /*--- -description: Dynamic import() returns a Promise object. (top level) +description: Dynamic import() returns a thenable object. (top level) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/top-level-import-then-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/top-level-import-then-specifier-tostring.js new file mode 100644 index 0000000000000000000000000000000000000000..41db37522a334acb15de1ba4e2483b7c4c9e91d0 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/top-level-import-then-specifier-tostring.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/top-level.template +/*--- +description: ToString value of specifier (top level) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + +}).then($DONE, $DONE).catch($DONE);