From 1c119e323e1a3d6d14a79a815603850459808ec9 Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Tue, 9 Oct 2018 17:06:27 -0400 Subject: [PATCH] Generate tests --- .../await-imported-Symbol-toStringTag.js | 98 +++++++++++++++++ .../await-imported-extensible.js | 81 ++++++++++++++ .../await-imported-no-iterator.js | 80 ++++++++++++++ .../await-imported-prop-descs.js | 103 ++++++++++++++++++ .../await-imported-prototype.js | 80 ++++++++++++++ ...romise-then-imported-Symbol-toStringTag.js | 96 ++++++++++++++++ .../promise-then-imported-extensible.js | 79 ++++++++++++++ .../promise-then-imported-no-iterator.js | 78 +++++++++++++ .../promise-then-imported-prop-descs.js | 101 +++++++++++++++++ .../promise-then-imported-prototype.js | 78 +++++++++++++ 10 files changed, 874 insertions(+) create mode 100644 test/language/module-code/dynamic-import/module-namespace-object/await-imported-Symbol-toStringTag.js create mode 100644 test/language/module-code/dynamic-import/module-namespace-object/await-imported-extensible.js create mode 100644 test/language/module-code/dynamic-import/module-namespace-object/await-imported-no-iterator.js create mode 100644 test/language/module-code/dynamic-import/module-namespace-object/await-imported-prop-descs.js create mode 100644 test/language/module-code/dynamic-import/module-namespace-object/await-imported-prototype.js create mode 100644 test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-Symbol-toStringTag.js create mode 100644 test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-extensible.js create mode 100644 test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-no-iterator.js create mode 100644 test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-prop-descs.js create mode 100644 test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-prototype.js diff --git a/test/language/module-code/dynamic-import/module-namespace-object/await-imported-Symbol-toStringTag.js b/test/language/module-code/dynamic-import/module-namespace-object/await-imported-Symbol-toStringTag.js new file mode 100644 index 0000000000..3c827d53d9 --- /dev/null +++ b/test/language/module-code/dynamic-import/module-namespace-object/await-imported-Symbol-toStringTag.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/imported-Symbol-toStringTag.case +// - src/dynamic-import/module-namespace-object/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 imported = await import('./module-code_FIXTURE.js'); + + assert.sameValue(imported[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(imported, 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/module-namespace-object/await-imported-extensible.js b/test/language/module-code/dynamic-import/module-namespace-object/await-imported-extensible.js new file mode 100644 index 0000000000..fd98e278c3 --- /dev/null +++ b/test/language/module-code/dynamic-import/module-namespace-object/await-imported-extensible.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/imported-extensible.case +// - src/dynamic-import/module-namespace-object/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 imported = await import('./module-code_FIXTURE.js'); + + assert.sameValue(Object.isExtensible(imported), false); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/module-namespace-object/await-imported-no-iterator.js b/test/language/module-code/dynamic-import/module-namespace-object/await-imported-no-iterator.js new file mode 100644 index 0000000000..cb8f65b31d --- /dev/null +++ b/test/language/module-code/dynamic-import/module-namespace-object/await-imported-no-iterator.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/imported-no-iterator.case +// - src/dynamic-import/module-namespace-object/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 imported = await import('./module-code_FIXTURE.js'); + + assert.sameValue(Object.prototype.hasOwnProperty.call(imported, Symbol.iterator), false); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/module-namespace-object/await-imported-prop-descs.js b/test/language/module-code/dynamic-import/module-namespace-object/await-imported-prop-descs.js new file mode 100644 index 0000000000..2633a30525 --- /dev/null +++ b/test/language/module-code/dynamic-import/module-namespace-object/await-imported-prop-descs.js @@ -0,0 +1,103 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/imported-prop-descs.case +// - src/dynamic-import/module-namespace-object/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 imported = 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(imported, 'default'); + +assert.sameValue(desc.value, 42, 'default value is 42'); +assert.sameValue(desc.enumerable, true, 'default reports as enumerable'); +assert.sameValue(desc.writable, true, 'default reports as writable'); +assert.sameValue(desc.configurable, false, 'default reports as non-configurable'); + +desc = Object.getOwnPropertyDescriptor(imported, 'x'); + +assert.sameValue(desc.value, 'Test262', 'x value is "Test262"'); +assert.sameValue(desc.enumerable, true, 'x reports as enumerable'); +assert.sameValue(desc.writable, true, 'x reports as writable'); +assert.sameValue(desc.configurable, false, 'x reports as non-configurable'); + +desc = Object.getOwnPropertyDescriptor(imported, 'z'); + +assert.sameValue(desc.value, 42, 'z value is 42'); +assert.sameValue(desc.enumerable, true, 'z reports as enumerable'); +assert.sameValue(desc.writable, true, 'z reports as writable'); +assert.sameValue(desc.configurable, false, 'z reports as non-configurable'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/module-namespace-object/await-imported-prototype.js b/test/language/module-code/dynamic-import/module-namespace-object/await-imported-prototype.js new file mode 100644 index 0000000000..d8fe1b5328 --- /dev/null +++ b/test/language/module-code/dynamic-import/module-namespace-object/await-imported-prototype.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/imported-prototype.case +// - src/dynamic-import/module-namespace-object/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 imported = await import('./module-code_FIXTURE.js'); + + assert.sameValue(Object.getPrototypeOf(imported), null, 'prototype is null'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-Symbol-toStringTag.js b/test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-Symbol-toStringTag.js new file mode 100644 index 0000000000..5f71cdc3a7 --- /dev/null +++ b/test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-Symbol-toStringTag.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/imported-Symbol-toStringTag.case +// - src/dynamic-import/module-namespace-object/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(imported => { + + assert.sameValue(imported[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(imported, 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/module-namespace-object/promise-then-imported-extensible.js b/test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-extensible.js new file mode 100644 index 0000000000..5bc9b868ca --- /dev/null +++ b/test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-extensible.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/imported-extensible.case +// - src/dynamic-import/module-namespace-object/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(imported => { + + assert.sameValue(Object.isExtensible(imported), false); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-no-iterator.js b/test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-no-iterator.js new file mode 100644 index 0000000000..e0d739dfc8 --- /dev/null +++ b/test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-no-iterator.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/imported-no-iterator.case +// - src/dynamic-import/module-namespace-object/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(imported => { + + assert.sameValue(Object.prototype.hasOwnProperty.call(imported, Symbol.iterator), false); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-prop-descs.js b/test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-prop-descs.js new file mode 100644 index 0000000000..9299fdae37 --- /dev/null +++ b/test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-prop-descs.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/imported-prop-descs.case +// - src/dynamic-import/module-namespace-object/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(imported => { + + // 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(imported, 'default'); + +assert.sameValue(desc.value, 42, 'default value is 42'); +assert.sameValue(desc.enumerable, true, 'default reports as enumerable'); +assert.sameValue(desc.writable, true, 'default reports as writable'); +assert.sameValue(desc.configurable, false, 'default reports as non-configurable'); + +desc = Object.getOwnPropertyDescriptor(imported, 'x'); + +assert.sameValue(desc.value, 'Test262', 'x value is "Test262"'); +assert.sameValue(desc.enumerable, true, 'x reports as enumerable'); +assert.sameValue(desc.writable, true, 'x reports as writable'); +assert.sameValue(desc.configurable, false, 'x reports as non-configurable'); + +desc = Object.getOwnPropertyDescriptor(imported, 'z'); + +assert.sameValue(desc.value, 42, 'z value is 42'); +assert.sameValue(desc.enumerable, true, 'z reports as enumerable'); +assert.sameValue(desc.writable, true, 'z reports as writable'); +assert.sameValue(desc.configurable, false, 'z reports as non-configurable'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-prototype.js b/test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-prototype.js new file mode 100644 index 0000000000..e5a1a00f68 --- /dev/null +++ b/test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-prototype.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/imported-prototype.case +// - src/dynamic-import/module-namespace-object/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(imported => { + + assert.sameValue(Object.getPrototypeOf(imported), null, 'prototype is null'); + +}).then($DONE, $DONE).catch($DONE);