From b0ec060e62f8e973d92cb7810adb59dfc2ef54ac Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Tue, 9 Oct 2018 14:10:29 -0400 Subject: [PATCH 01/14] Add more cases for Dynamic Imports usage - Add cases for mixing module and script code - Rename test case from return promise to thenable - Fix script code case with valid loaded fixture - Add a test to assert a promise return - Add case for specifier toString rejection - Add case for specifier toString - Test Assignment expression abrupt completion - Test Promise return --- ...script-code-host-resolves-module-code.case | 18 +++++++ .../eval-script-code-target.case | 22 ++++++++ ...rns-promise.case => returns-thenable.case} | 2 +- src/dynamic-import/script-code-valid.case | 2 +- .../specifier-tostring-abrupt-rejects.case | 36 +++++++++++++ src/dynamic-import/specifier-tostring.case | 38 +++++++++++++ .../assign-expr-get-value-abrupt-throws.js | 37 +++++++++++++ .../catch/script-code_FIXTURE.js | 7 +++ .../dynamic-import-module_FIXTURE.js | 4 ++ .../dynamic-import/returns-promise.js | 53 +++++++++++++++++++ .../usage/module-code_FIXTURE.js | 8 +++ 11 files changed, 225 insertions(+), 2 deletions(-) create mode 100644 src/dynamic-import/eval-script-code-host-resolves-module-code.case create mode 100644 src/dynamic-import/eval-script-code-target.case rename src/dynamic-import/{returns-promise.case => returns-thenable.case} (86%) create mode 100644 src/dynamic-import/specifier-tostring-abrupt-rejects.case create mode 100644 src/dynamic-import/specifier-tostring.case create mode 100644 test/language/module-code/dynamic-import/assign-expr-get-value-abrupt-throws.js create mode 100644 test/language/module-code/dynamic-import/catch/script-code_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/dynamic-import-module_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/returns-promise.js create mode 100644 test/language/module-code/dynamic-import/usage/module-code_FIXTURE.js 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 0000000000..4963710137 --- /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 0000000000..a73dfc91d9 --- /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/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 e03f674d31..f62fe38919 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 1c4f813a06..8304af7ed2 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 0000000000..7a67f6ea9e --- /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 0000000000..d09cca31bd --- /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 0000000000..acd0d96a7f --- /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/script-code_FIXTURE.js b/test/language/module-code/dynamic-import/catch/script-code_FIXTURE.js new file mode 100644 index 0000000000..131ffcee71 --- /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/dynamic-import-module_FIXTURE.js b/test/language/module-code/dynamic-import/dynamic-import-module_FIXTURE.js new file mode 100644 index 0000000000..ef3f4207cd --- /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/returns-promise.js b/test/language/module-code/dynamic-import/returns-promise.js new file mode 100644 index 0000000000..e44f6e24eb --- /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/usage/module-code_FIXTURE.js b/test/language/module-code/dynamic-import/usage/module-code_FIXTURE.js new file mode 100644 index 0000000000..96b0503d95 --- /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 }; From f8fda5b6d2c8f399d0c08011621081650896683a Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Tue, 9 Oct 2018 14:16:50 -0400 Subject: [PATCH 02/14] Remove nested-with template for usage/catch tests This should be well covered in the syntax templates and opens the path for tests with module code restrictions --- src/dynamic-import/catch/nested-with.template | 31 ---------- .../default/nested-with.template | 30 ---------- ...mport-catch-eval-rqstd-abrupt-typeerror.js | 39 ------------ ...import-catch-eval-rqstd-abrupt-urierror.js | 39 ------------ ...d-with-import-catch-file-does-not-exist.js | 36 ----------- ...rt-catch-instn-iee-err-ambiguous-import.js | 60 ------------------- ...ith-import-catch-instn-iee-err-circular.js | 49 --------------- 7 files changed, 284 deletions(-) delete mode 100644 src/dynamic-import/catch/nested-with.template delete mode 100644 src/dynamic-import/default/nested-with.template delete mode 100644 test/language/module-code/dynamic-import/catch/nested-with-import-catch-eval-rqstd-abrupt-typeerror.js delete mode 100644 test/language/module-code/dynamic-import/catch/nested-with-import-catch-eval-rqstd-abrupt-urierror.js delete mode 100644 test/language/module-code/dynamic-import/catch/nested-with-import-catch-file-does-not-exist.js delete mode 100644 test/language/module-code/dynamic-import/catch/nested-with-import-catch-instn-iee-err-ambiguous-import.js delete mode 100644 test/language/module-code/dynamic-import/catch/nested-with-import-catch-instn-iee-err-circular.js diff --git a/src/dynamic-import/catch/nested-with.template b/src/dynamic-import/catch/nested-with.template deleted file mode 100644 index e88b46e674..0000000000 --- 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 0520321497..0000000000 --- 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/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 cf8b175614..0000000000 --- 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 7544674b0b..0000000000 --- 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 082c42f568..0000000000 --- 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 028e8d5104..0000000000 --- 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 07dd99c501..0000000000 --- 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 From 070198fbadfe84843b911d304497af8a8c2db46c Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Tue, 9 Oct 2018 14:17:35 -0400 Subject: [PATCH 03/14] Generate tests --- ...ow-import-catch-eval-script-code-target.js | 42 ++++++++++++++ ...catch-specifier-tostring-abrupt-rejects.js | 55 ++++++++++++++++++ ...-function-await-eval-script-code-target.js | 42 ++++++++++++++ ...await-specifier-tostring-abrupt-rejects.js | 55 ++++++++++++++++++ ...-async-function-eval-script-code-target.js | 43 ++++++++++++++ ...on-return-await-eval-script-code-target.js | 42 ++++++++++++++ ...await-specifier-tostring-abrupt-rejects.js | 55 ++++++++++++++++++ ...ction-specifier-tostring-abrupt-rejects.js | 56 ++++++++++++++++++ ...ck-import-catch-eval-script-code-target.js | 40 +++++++++++++ ...catch-specifier-tostring-abrupt-rejects.js | 53 +++++++++++++++++ ...d-block-labeled-eval-script-code-target.js | 40 +++++++++++++ ...beled-specifier-tostring-abrupt-rejects.js | 53 +++++++++++++++++ ...nested-do-while-eval-script-code-target.js | 40 +++++++++++++ ...while-specifier-tostring-abrupt-rejects.js | 53 +++++++++++++++++ ...se-import-catch-eval-script-code-target.js | 42 ++++++++++++++ ...catch-specifier-tostring-abrupt-rejects.js | 55 ++++++++++++++++++ ...on-import-catch-eval-script-code-target.js | 41 +++++++++++++ ...catch-specifier-tostring-abrupt-rejects.js | 54 +++++++++++++++++ ...if-import-catch-eval-script-code-target.js | 40 +++++++++++++ ...catch-specifier-tostring-abrupt-rejects.js | 53 +++++++++++++++++ ...le-import-catch-eval-script-code-target.js | 42 ++++++++++++++ ...catch-specifier-tostring-abrupt-rejects.js | 55 ++++++++++++++++++ ...el-import-catch-eval-script-code-target.js | 38 ++++++++++++ ...catch-specifier-tostring-abrupt-rejects.js | 51 ++++++++++++++++ ...assignment-expression-script-code-valid.js | 2 +- .../valid/nested-arrow-script-code-valid.js | 2 +- ...-async-function-await-script-code-valid.js | 2 +- ...function-return-await-script-code-valid.js | 2 +- ...nested-async-function-script-code-valid.js | 2 +- .../nested-block-labeled-script-code-valid.js | 2 +- .../valid/nested-block-script-code-valid.js | 2 +- .../nested-do-while-script-code-valid.js | 2 +- ...nested-else-braceless-script-code-valid.js | 2 +- .../valid/nested-else-script-code-valid.js | 2 +- ...ested-function-return-script-code-valid.js | 2 +- .../nested-function-script-code-valid.js | 2 +- .../nested-if-braceless-script-code-valid.js | 2 +- .../valid/nested-if-script-code-valid.js | 2 +- .../valid/nested-while-script-code-valid.js | 2 +- .../valid/nested-with-script-code-valid.js | 2 +- .../valid/top-level-script-code-valid.js | 2 +- ...l-script-code-host-resolves-module-code.js | 38 ++++++++++++ ...assignment-expression-returns-thenable.js} | 4 +- ...ssignment-expression-specifier-tostring.js | 56 ++++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 40 +++++++++++++ ...ted-arrow-import-then-returns-thenable.js} | 4 +- ...ed-arrow-import-then-specifier-tostring.js | 58 +++++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 39 +++++++++++++ ...-async-function-await-returns-thenable.js} | 4 +- ...async-function-await-specifier-tostring.js | 57 ++++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 39 +++++++++++++ ...l-script-code-host-resolves-module-code.js | 39 +++++++++++++ ...function-return-await-returns-thenable.js} | 4 +- ...unction-return-await-specifier-tostring.js | 57 ++++++++++++++++++ ...nested-async-function-returns-thenable.js} | 4 +- ...ested-async-function-specifier-tostring.js | 57 ++++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 37 ++++++++++++ ...ted-block-import-then-returns-thenable.js} | 4 +- ...ed-block-import-then-specifier-tostring.js | 55 ++++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 37 ++++++++++++ ...js => nested-do-while-returns-thenable.js} | 4 +- .../nested-do-while-specifier-tostring.js | 55 ++++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 39 +++++++++++++ ...sted-else-import-then-returns-thenable.js} | 4 +- ...ted-else-import-then-specifier-tostring.js | 57 ++++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 38 ++++++++++++ ...-function-import-then-returns-thenable.js} | 4 +- ...function-import-then-specifier-tostring.js | 56 ++++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 35 +++++++++++ ...> nested-if-braceless-returns-thenable.js} | 4 +- .../nested-if-braceless-specifier-tostring.js | 53 +++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 37 ++++++++++++ ...nested-if-import-then-returns-thenable.js} | 4 +- ...ested-if-import-then-specifier-tostring.js | 55 ++++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 39 +++++++++++++ ...ted-while-import-then-returns-thenable.js} | 4 +- ...ed-while-import-then-specifier-tostring.js | 57 ++++++++++++++++++ ...-then-eval-gtbndng-indirect-update-dflt.js | 44 -------------- ...mport-then-eval-gtbndng-indirect-update.js | 52 ----------------- ...then-is-call-expression-square-brackets.js | 31 ---------- ...nested-with-import-then-returns-promise.js | 31 ---------- ...l-script-code-host-resolves-module-code.js | 37 ++++++++++++ ...-nested-block-labeled-returns-thenable.js} | 4 +- ...nested-block-labeled-specifier-tostring.js | 55 ++++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 35 +++++++++++ ...top-level-import-then-returns-thenable.js} | 4 +- ...op-level-import-then-specifier-tostring.js | 53 +++++++++++++++++ 87 files changed, 2495 insertions(+), 203 deletions(-) create mode 100644 test/language/module-code/dynamic-import/catch/nested-arrow-import-catch-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-arrow-import-catch-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-function-await-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-function-await-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-function-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-function-return-await-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-function-return-await-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-function-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-block-import-catch-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-block-import-catch-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-block-labeled-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-block-labeled-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-do-while-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-do-while-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-else-import-catch-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-else-import-catch-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-function-import-catch-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-function-import-catch-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-if-import-catch-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-if-import-catch-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-while-import-catch-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-while-import-catch-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/top-level-import-catch-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/top-level-import-catch-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-arrow-assignment-expression-returns-promise.js => nested-arrow-assignment-expression-returns-thenable.js} (90%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-arrow-import-then-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-arrow-import-then-returns-promise.js => nested-arrow-import-then-returns-thenable.js} (90%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-arrow-import-then-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-function-await-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-async-function-await-returns-promise.js => nested-async-function-await-returns-thenable.js} (88%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-function-await-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-function-eval-script-code-host-resolves-module-code.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-function-return-await-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-async-function-return-await-returns-promise.js => nested-async-function-return-await-returns-thenable.js} (88%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-function-return-await-specifier-tostring.js rename test/language/module-code/dynamic-import/usage/{nested-async-function-returns-promise.js => nested-async-function-returns-thenable.js} (89%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-function-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-block-import-then-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-block-import-then-returns-promise.js => nested-block-import-then-returns-thenable.js} (90%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-block-import-then-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-do-while-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-do-while-returns-promise.js => nested-do-while-returns-thenable.js} (89%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-do-while-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-else-import-then-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-else-import-then-returns-promise.js => nested-else-import-then-returns-thenable.js} (90%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-else-import-then-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-function-import-then-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-function-import-then-returns-promise.js => nested-function-import-then-returns-thenable.js} (90%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-function-import-then-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-if-braceless-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-if-braceless-returns-promise.js => nested-if-braceless-returns-thenable.js} (89%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-if-braceless-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-if-import-then-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-if-import-then-returns-promise.js => nested-if-import-then-returns-thenable.js} (90%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-if-import-then-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-while-import-then-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-while-import-then-returns-promise.js => nested-while-import-then-returns-thenable.js} (90%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-while-import-then-specifier-tostring.js delete mode 100644 test/language/module-code/dynamic-import/usage/nested-with-import-then-eval-gtbndng-indirect-update-dflt.js delete mode 100644 test/language/module-code/dynamic-import/usage/nested-with-import-then-eval-gtbndng-indirect-update.js delete mode 100644 test/language/module-code/dynamic-import/usage/nested-with-import-then-is-call-expression-square-brackets.js delete mode 100644 test/language/module-code/dynamic-import/usage/nested-with-import-then-returns-promise.js create mode 100644 test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{syntax-nested-block-labeled-returns-promise.js => syntax-nested-block-labeled-returns-thenable.js} (89%) create mode 100644 test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/top-level-import-then-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{top-level-import-then-returns-promise.js => top-level-import-then-returns-thenable.js} (90%) create mode 100644 test/language/module-code/dynamic-import/usage/top-level-import-then-specifier-tostring.js 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 0000000000..fa6011eea3 --- /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 0000000000..c5ed7e5264 --- /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 0000000000..94703c2121 --- /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 0000000000..64e013be11 --- /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 0000000000..c2b5b19daa --- /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 0000000000..f63156e9e0 --- /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 0000000000..f3ec1bfb54 --- /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 0000000000..70e3352eb0 --- /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 0000000000..aa11268fa6 --- /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 0000000000..4a6398c768 --- /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 0000000000..7beb7101b1 --- /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 0000000000..b6723a7059 --- /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 0000000000..4fd908472d --- /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 0000000000..7525280a08 --- /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 0000000000..001ff761a6 --- /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 0000000000..6d8e0223ba --- /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 0000000000..f1f8d81cb3 --- /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 0000000000..1917a05566 --- /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 0000000000..86a7e0250f --- /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 0000000000..eca30e05e0 --- /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 0000000000..8676fd92c4 --- /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 0000000000..ddf0987e06 --- /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/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 0000000000..daae4c13fe --- /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 0000000000..02ecae37f5 --- /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/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 c5654cd220..c2f9ad358f 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 590fff106f..d0b96c3678 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 90849fabfe..111ba41252 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 f383065913..94225d6120 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 e00d0a7ffd..9b28f3564e 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 0d36b64b70..cce923e15e 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 f66e994bd0..5cad7f4698 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 1b86097b58..e667c594e0 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 4426fcca22..d71f70bef9 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 7ec91b881a..b621c6ff78 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 5a871fa54a..0719c15fca 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 68f127e3e1..cdf6fc0555 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 e449237b2b..b01c66b8d9 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 f2b1eb9c25..89fa4f15eb 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 b196e203ea..48a0a3cb0e 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 b46979d5ec..7334f88709 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 3aa54554ba..c04af7884f 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/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 0000000000..09c4d51abc --- /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 463c475f53..b72f8acdf6 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 0000000000..3b51623c57 --- /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 0000000000..25bffd3125 --- /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 0a5edbe9bc..b726b0af63 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 0000000000..442d5cf63d --- /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 0000000000..49578b5928 --- /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 065feb806f..24eb32af41 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 0000000000..6906ae7d56 --- /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 0000000000..71148fc8f7 --- /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 0000000000..173933e313 --- /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 135a98225e..0541c60034 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 0000000000..260d2b96ba --- /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 435b3e0d3e..943efb3acd 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 0000000000..8ee53673db --- /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 0000000000..73047f13b4 --- /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 997722f966..a5340ac60c 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 0000000000..73d4238486 --- /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 0000000000..0d03d24fac --- /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 1907481f2c..7cd332dd3c 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 0000000000..e352bbdffa --- /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 0000000000..fd0ba3df2c --- /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 afde7ff219..b3d67e51e9 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 0000000000..e30494dbd9 --- /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 0000000000..1c5d97e525 --- /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 ab2ff9bfa3..53883c1866 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 0000000000..49178a51de --- /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 0000000000..e41cca7565 --- /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 37710f3aad..1701a0f191 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 0000000000..b41dd64029 --- /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 0000000000..2c0d6ca1cd --- /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 57f9e7dc83..e16fce3637 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 0000000000..44e2a5cb53 --- /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 0000000000..0fb62b6e7f --- /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 f4bef3e87b..2d6ae02f6b 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 0000000000..749504ffc1 --- /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 c8232adb17..0000000000 --- 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 d39cd5cfae..0000000000 --- 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 18d95fe17a..0000000000 --- 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 0b17dd7aeb..0000000000 --- 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 0000000000..de78996dd4 --- /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 877e77c22e..9eae36c213 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 0000000000..e784c53fc3 --- /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 0000000000..e8e6f7578b --- /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 626bc97eda..ea980190d4 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 0000000000..41db37522a --- /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); From dc2da1558f6f8c1c750f2ee9950d605189c64fc9 Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Tue, 9 Oct 2018 17:06:19 -0400 Subject: [PATCH 04/14] Add tests for the resolved namespace obj --- .../imported-Symbol-toStringTag.case | 29 +++++++ src/dynamic-import/imported-extensible.case | 12 +++ src/dynamic-import/imported-no-iterator.case | 13 +++ src/dynamic-import/imported-prop-descs.case | 34 ++++++++ src/dynamic-import/imported-prototype.case | 11 +++ .../module-namespace-object/await.template | 81 +++++++++++++++++++ .../module-namespace-object/promise.template | 79 ++++++++++++++++++ .../module-code_FIXTURE.js | 8 ++ 8 files changed, 267 insertions(+) create mode 100644 src/dynamic-import/imported-Symbol-toStringTag.case create mode 100644 src/dynamic-import/imported-extensible.case create mode 100644 src/dynamic-import/imported-no-iterator.case create mode 100644 src/dynamic-import/imported-prop-descs.case create mode 100644 src/dynamic-import/imported-prototype.case create mode 100644 src/dynamic-import/module-namespace-object/await.template create mode 100644 src/dynamic-import/module-namespace-object/promise.template create mode 100644 test/language/module-code/dynamic-import/module-namespace-object/module-code_FIXTURE.js diff --git a/src/dynamic-import/imported-Symbol-toStringTag.case b/src/dynamic-import/imported-Symbol-toStringTag.case new file mode 100644 index 0000000000..99d43b22da --- /dev/null +++ b/src/dynamic-import/imported-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: module-namespace-object +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(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'); diff --git a/src/dynamic-import/imported-extensible.case b/src/dynamic-import/imported-extensible.case new file mode 100644 index 0000000000..15e87c6097 --- /dev/null +++ b/src/dynamic-import/imported-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: module-namespace-object +includes: [propertyHelper.js] +---*/ + +//- import +import('./module-code_FIXTURE.js') +//- body +assert.sameValue(Object.isExtensible(imported), false); diff --git a/src/dynamic-import/imported-no-iterator.case b/src/dynamic-import/imported-no-iterator.case new file mode 100644 index 0000000000..0999a89ddd --- /dev/null +++ b/src/dynamic-import/imported-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: module-namespace-object +features: [Symbol.iterator] +---*/ + +//- import +import('./module-code_FIXTURE.js') +//- body +assert.sameValue(Object.prototype.hasOwnProperty.call(imported, Symbol.iterator), false); diff --git a/src/dynamic-import/imported-prop-descs.case b/src/dynamic-import/imported-prop-descs.case new file mode 100644 index 0000000000..55edf6daa1 --- /dev/null +++ b/src/dynamic-import/imported-prop-descs.case @@ -0,0 +1,34 @@ +// 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: module-namespace-object +---*/ + +//- 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(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'); diff --git a/src/dynamic-import/imported-prototype.case b/src/dynamic-import/imported-prototype.case new file mode 100644 index 0000000000..fd5c281749 --- /dev/null +++ b/src/dynamic-import/imported-prototype.case @@ -0,0 +1,11 @@ +// 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: module-namespace-object +---*/ + +//- import +import('./module-code_FIXTURE.js') +//- body +assert.sameValue(Object.getPrototypeOf(imported), null, 'prototype is null'); diff --git a/src/dynamic-import/module-namespace-object/await.template b/src/dynamic-import/module-namespace-object/await.template new file mode 100644 index 0000000000..bc79c102ab --- /dev/null +++ b/src/dynamic-import/module-namespace-object/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/module-namespace-object/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 imported = await /*{ import }*/; + + /*{ body }*/ +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/src/dynamic-import/module-namespace-object/promise.template b/src/dynamic-import/module-namespace-object/promise.template new file mode 100644 index 0000000000..7da1a8e9c5 --- /dev/null +++ b/src/dynamic-import/module-namespace-object/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/module-namespace-object/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(imported => { + + /*{ body }*/ + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/module-namespace-object/module-code_FIXTURE.js b/test/language/module-code/dynamic-import/module-namespace-object/module-code_FIXTURE.js new file mode 100644 index 0000000000..96b0503d95 --- /dev/null +++ b/test/language/module-code/dynamic-import/module-namespace-object/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 }; From 1c119e323e1a3d6d14a79a815603850459808ec9 Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Tue, 9 Oct 2018 17:06:27 -0400 Subject: [PATCH 05/14] 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); From ec1d7ccc6fe50f6b57aee611b0fccf60c4eebd85 Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Tue, 9 Oct 2018 18:05:39 -0400 Subject: [PATCH 06/14] Rename imported to namespace --- .../{module-namespace-object => namespace}/await.template | 4 ++-- .../promise.template | 4 ++-- ...Symbol-toStringTag.case => ns-Symbol-toStringTag.case} | 6 +++--- .../{imported-extensible.case => ns-extensible.case} | 4 ++-- .../{imported-no-iterator.case => ns-no-iterator.case} | 4 ++-- .../{imported-prop-descs.case => ns-prop-descs.case} | 8 ++++---- .../{imported-prototype.case => ns-prototype.case} | 4 ++-- .../module-code_FIXTURE.js | 0 8 files changed, 17 insertions(+), 17 deletions(-) rename src/dynamic-import/{module-namespace-object => namespace}/await.template (96%) rename src/dynamic-import/{module-namespace-object => namespace}/promise.template (97%) rename src/dynamic-import/{imported-Symbol-toStringTag.case => ns-Symbol-toStringTag.case} (85%) rename src/dynamic-import/{imported-extensible.case => ns-extensible.case} (75%) rename src/dynamic-import/{imported-no-iterator.case => ns-no-iterator.case} (73%) rename src/dynamic-import/{imported-prop-descs.case => ns-prop-descs.case} (86%) rename src/dynamic-import/{imported-prototype.case => ns-prototype.case} (68%) rename test/language/module-code/dynamic-import/{module-namespace-object => ns}/module-code_FIXTURE.js (100%) diff --git a/src/dynamic-import/module-namespace-object/await.template b/src/dynamic-import/namespace/await.template similarity index 96% rename from src/dynamic-import/module-namespace-object/await.template rename to src/dynamic-import/namespace/await.template index bc79c102ab..f2ad5afe0a 100644 --- a/src/dynamic-import/module-namespace-object/await.template +++ b/src/dynamic-import/namespace/await.template @@ -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. /*--- -path: language/module-code/dynamic-import/module-namespace-object/await- +path: language/module-code/dynamic-import/ns/await- name: value from await resolving esid: sec-finishdynamicimport info: | @@ -73,7 +73,7 @@ flags: [async] ---*/ async function fn() { - const imported = await /*{ import }*/; + const ns = await /*{ import }*/; /*{ body }*/ } diff --git a/src/dynamic-import/module-namespace-object/promise.template b/src/dynamic-import/namespace/promise.template similarity index 97% rename from src/dynamic-import/module-namespace-object/promise.template rename to src/dynamic-import/namespace/promise.template index 7da1a8e9c5..fce701c04b 100644 --- a/src/dynamic-import/module-namespace-object/promise.template +++ b/src/dynamic-import/namespace/promise.template @@ -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. /*--- -path: language/module-code/dynamic-import/module-namespace-object/promise-then- +path: language/module-code/dynamic-import/ns/promise-then- name: value from promise then esid: sec-finishdynamicimport info: | @@ -72,7 +72,7 @@ features: [dynamic-import] flags: [async] ---*/ -/*{ import }*/.then(imported => { +/*{ import }*/.then(ns => { /*{ body }*/ diff --git a/src/dynamic-import/imported-Symbol-toStringTag.case b/src/dynamic-import/ns-Symbol-toStringTag.case similarity index 85% rename from src/dynamic-import/imported-Symbol-toStringTag.case rename to src/dynamic-import/ns-Symbol-toStringTag.case index 99d43b22da..9ac7e8b62e 100644 --- a/src/dynamic-import/imported-Symbol-toStringTag.case +++ b/src/dynamic-import/ns-Symbol-toStringTag.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- desc: Module namespace objects have a Symbol.toStringTag -template: module-namespace-object +template: namespace info: | @@toStringTag @@ -16,13 +16,13 @@ features: [Symbol.toStringTag] //- import import('./module-code_FIXTURE.js') //- body -assert.sameValue(imported[Symbol.toStringTag], 'Module'); +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(imported, Symbol.toStringTag); +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'); diff --git a/src/dynamic-import/imported-extensible.case b/src/dynamic-import/ns-extensible.case similarity index 75% rename from src/dynamic-import/imported-extensible.case rename to src/dynamic-import/ns-extensible.case index 15e87c6097..b54a0c88d6 100644 --- a/src/dynamic-import/imported-extensible.case +++ b/src/dynamic-import/ns-extensible.case @@ -2,11 +2,11 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- desc: Module namespace objects are not extensible. -template: module-namespace-object +template: namespace includes: [propertyHelper.js] ---*/ //- import import('./module-code_FIXTURE.js') //- body -assert.sameValue(Object.isExtensible(imported), false); +assert.sameValue(Object.isExtensible(ns), false); diff --git a/src/dynamic-import/imported-no-iterator.case b/src/dynamic-import/ns-no-iterator.case similarity index 73% rename from src/dynamic-import/imported-no-iterator.case rename to src/dynamic-import/ns-no-iterator.case index 0999a89ddd..9e082e3c11 100644 --- a/src/dynamic-import/imported-no-iterator.case +++ b/src/dynamic-import/ns-no-iterator.case @@ -3,11 +3,11 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- desc: Module namespace objects lack a Symbol.toStringTag -template: module-namespace-object +template: namespace features: [Symbol.iterator] ---*/ //- import import('./module-code_FIXTURE.js') //- body -assert.sameValue(Object.prototype.hasOwnProperty.call(imported, Symbol.iterator), false); +assert.sameValue(Object.prototype.hasOwnProperty.call(ns, Symbol.iterator), false); diff --git a/src/dynamic-import/imported-prop-descs.case b/src/dynamic-import/ns-prop-descs.case similarity index 86% rename from src/dynamic-import/imported-prop-descs.case rename to src/dynamic-import/ns-prop-descs.case index 55edf6daa1..ad873e711d 100644 --- a/src/dynamic-import/imported-prop-descs.case +++ b/src/dynamic-import/ns-prop-descs.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- desc: imported object properties descriptors -template: module-namespace-object +template: namespace ---*/ //- import @@ -12,21 +12,21 @@ import('./module-code_FIXTURE.js') // 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'); +var desc = Object.getOwnPropertyDescriptor(ns, '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'); +desc = Object.getOwnPropertyDescriptor(ns, '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'); +desc = Object.getOwnPropertyDescriptor(ns, 'z'); assert.sameValue(desc.value, 42, 'z value is 42'); assert.sameValue(desc.enumerable, true, 'z reports as enumerable'); diff --git a/src/dynamic-import/imported-prototype.case b/src/dynamic-import/ns-prototype.case similarity index 68% rename from src/dynamic-import/imported-prototype.case rename to src/dynamic-import/ns-prototype.case index fd5c281749..3a8d66d41e 100644 --- a/src/dynamic-import/imported-prototype.case +++ b/src/dynamic-import/ns-prototype.case @@ -2,10 +2,10 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- desc: Module namespace object prototype is null -template: module-namespace-object +template: namespace ---*/ //- import import('./module-code_FIXTURE.js') //- body -assert.sameValue(Object.getPrototypeOf(imported), null, 'prototype is null'); +assert.sameValue(Object.getPrototypeOf(ns), null, 'prototype is null'); diff --git a/test/language/module-code/dynamic-import/module-namespace-object/module-code_FIXTURE.js b/test/language/module-code/dynamic-import/ns/module-code_FIXTURE.js similarity index 100% rename from test/language/module-code/dynamic-import/module-namespace-object/module-code_FIXTURE.js rename to test/language/module-code/dynamic-import/ns/module-code_FIXTURE.js From 019322b114f82b60ac28c28b98371415be2e55df Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Tue, 9 Oct 2018 18:08:17 -0400 Subject: [PATCH 07/14] Generate tests --- .../await-ns-Symbol-toStringTag.js} | 10 +++++----- .../await-ns-extensible.js} | 8 ++++---- .../await-ns-no-iterator.js} | 8 ++++---- .../await-ns-prop-descs.js} | 12 ++++++------ .../await-ns-prototype.js} | 8 ++++---- .../promise-then-ns-Symbol-toStringTag.js} | 10 +++++----- .../promise-then-ns-extensible.js} | 8 ++++---- .../promise-then-ns-no-iterator.js} | 8 ++++---- .../promise-then-ns-prop-descs.js} | 12 ++++++------ .../promise-then-ns-prototype.js} | 8 ++++---- 10 files changed, 46 insertions(+), 46 deletions(-) rename test/language/module-code/dynamic-import/{module-namespace-object/await-imported-Symbol-toStringTag.js => ns/await-ns-Symbol-toStringTag.js} (93%) rename test/language/module-code/dynamic-import/{module-namespace-object/await-imported-extensible.js => ns/await-ns-extensible.js} (94%) rename test/language/module-code/dynamic-import/{module-namespace-object/await-imported-no-iterator.js => ns/await-ns-no-iterator.js} (93%) rename test/language/module-code/dynamic-import/{module-namespace-object/await-imported-prop-descs.js => ns/await-ns-prop-descs.js} (93%) rename test/language/module-code/dynamic-import/{module-namespace-object/await-imported-prototype.js => ns/await-ns-prototype.js} (93%) rename test/language/module-code/dynamic-import/{module-namespace-object/promise-then-imported-Symbol-toStringTag.js => ns/promise-then-ns-Symbol-toStringTag.js} (93%) rename test/language/module-code/dynamic-import/{module-namespace-object/promise-then-imported-extensible.js => ns/promise-then-ns-extensible.js} (94%) rename test/language/module-code/dynamic-import/{module-namespace-object/promise-then-imported-no-iterator.js => ns/promise-then-ns-no-iterator.js} (93%) rename test/language/module-code/dynamic-import/{module-namespace-object/promise-then-imported-prop-descs.js => ns/promise-then-ns-prop-descs.js} (93%) rename test/language/module-code/dynamic-import/{module-namespace-object/promise-then-imported-prototype.js => ns/promise-then-ns-prototype.js} (93%) diff --git a/test/language/module-code/dynamic-import/module-namespace-object/await-imported-Symbol-toStringTag.js b/test/language/module-code/dynamic-import/ns/await-ns-Symbol-toStringTag.js similarity index 93% rename from test/language/module-code/dynamic-import/module-namespace-object/await-imported-Symbol-toStringTag.js rename to test/language/module-code/dynamic-import/ns/await-ns-Symbol-toStringTag.js index 3c827d53d9..585a039ab0 100644 --- a/test/language/module-code/dynamic-import/module-namespace-object/await-imported-Symbol-toStringTag.js +++ b/test/language/module-code/dynamic-import/ns/await-ns-Symbol-toStringTag.js @@ -1,6 +1,6 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/imported-Symbol-toStringTag.case -// - src/dynamic-import/module-namespace-object/await.template +// - 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 @@ -80,15 +80,15 @@ info: | ---*/ async function fn() { - const imported = await import('./module-code_FIXTURE.js'); + const ns = await import('./module-code_FIXTURE.js'); - assert.sameValue(imported[Symbol.toStringTag], 'Module'); + 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(imported, Symbol.toStringTag); +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'); diff --git a/test/language/module-code/dynamic-import/module-namespace-object/await-imported-extensible.js b/test/language/module-code/dynamic-import/ns/await-ns-extensible.js similarity index 94% rename from test/language/module-code/dynamic-import/module-namespace-object/await-imported-extensible.js rename to test/language/module-code/dynamic-import/ns/await-ns-extensible.js index fd98e278c3..e35aa7418f 100644 --- a/test/language/module-code/dynamic-import/module-namespace-object/await-imported-extensible.js +++ b/test/language/module-code/dynamic-import/ns/await-ns-extensible.js @@ -1,6 +1,6 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/imported-extensible.case -// - src/dynamic-import/module-namespace-object/await.template +// - 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 @@ -73,9 +73,9 @@ info: | ---*/ async function fn() { - const imported = await import('./module-code_FIXTURE.js'); + const ns = await import('./module-code_FIXTURE.js'); - assert.sameValue(Object.isExtensible(imported), false); + assert.sameValue(Object.isExtensible(ns), 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/ns/await-ns-no-iterator.js similarity index 93% rename from test/language/module-code/dynamic-import/module-namespace-object/await-imported-no-iterator.js rename to test/language/module-code/dynamic-import/ns/await-ns-no-iterator.js index cb8f65b31d..fe17ef298b 100644 --- a/test/language/module-code/dynamic-import/module-namespace-object/await-imported-no-iterator.js +++ b/test/language/module-code/dynamic-import/ns/await-ns-no-iterator.js @@ -1,6 +1,6 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/imported-no-iterator.case -// - src/dynamic-import/module-namespace-object/await.template +// - 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 @@ -72,9 +72,9 @@ info: | ---*/ async function fn() { - const imported = await import('./module-code_FIXTURE.js'); + const ns = await import('./module-code_FIXTURE.js'); - assert.sameValue(Object.prototype.hasOwnProperty.call(imported, Symbol.iterator), false); + 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/module-namespace-object/await-imported-prop-descs.js b/test/language/module-code/dynamic-import/ns/await-ns-prop-descs.js similarity index 93% rename from test/language/module-code/dynamic-import/module-namespace-object/await-imported-prop-descs.js rename to test/language/module-code/dynamic-import/ns/await-ns-prop-descs.js index 2633a30525..3d0d29471a 100644 --- a/test/language/module-code/dynamic-import/module-namespace-object/await-imported-prop-descs.js +++ b/test/language/module-code/dynamic-import/ns/await-ns-prop-descs.js @@ -1,6 +1,6 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/imported-prop-descs.case -// - src/dynamic-import/module-namespace-object/await.template +// - 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 @@ -72,27 +72,27 @@ info: | ---*/ async function fn() { - const imported = await import('./module-code_FIXTURE.js'); + 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(imported, 'default'); +var desc = Object.getOwnPropertyDescriptor(ns, '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'); +desc = Object.getOwnPropertyDescriptor(ns, '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'); +desc = Object.getOwnPropertyDescriptor(ns, 'z'); assert.sameValue(desc.value, 42, 'z value is 42'); assert.sameValue(desc.enumerable, true, 'z reports as enumerable'); diff --git a/test/language/module-code/dynamic-import/module-namespace-object/await-imported-prototype.js b/test/language/module-code/dynamic-import/ns/await-ns-prototype.js similarity index 93% rename from test/language/module-code/dynamic-import/module-namespace-object/await-imported-prototype.js rename to test/language/module-code/dynamic-import/ns/await-ns-prototype.js index d8fe1b5328..4bbd93bbad 100644 --- a/test/language/module-code/dynamic-import/module-namespace-object/await-imported-prototype.js +++ b/test/language/module-code/dynamic-import/ns/await-ns-prototype.js @@ -1,6 +1,6 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/imported-prototype.case -// - src/dynamic-import/module-namespace-object/await.template +// - 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 @@ -72,9 +72,9 @@ info: | ---*/ async function fn() { - const imported = await import('./module-code_FIXTURE.js'); + const ns = await import('./module-code_FIXTURE.js'); - assert.sameValue(Object.getPrototypeOf(imported), null, 'prototype is null'); + assert.sameValue(Object.getPrototypeOf(ns), 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/ns/promise-then-ns-Symbol-toStringTag.js similarity index 93% rename from test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-Symbol-toStringTag.js rename to test/language/module-code/dynamic-import/ns/promise-then-ns-Symbol-toStringTag.js index 5f71cdc3a7..bb0e5f68d8 100644 --- a/test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-Symbol-toStringTag.js +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-Symbol-toStringTag.js @@ -1,6 +1,6 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/imported-Symbol-toStringTag.case -// - src/dynamic-import/module-namespace-object/promise.template +// - 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 @@ -79,15 +79,15 @@ info: | ---*/ -import('./module-code_FIXTURE.js').then(imported => { +import('./module-code_FIXTURE.js').then(ns => { - assert.sameValue(imported[Symbol.toStringTag], 'Module'); + 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(imported, Symbol.toStringTag); +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'); diff --git a/test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-extensible.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-extensible.js similarity index 94% rename from test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-extensible.js rename to test/language/module-code/dynamic-import/ns/promise-then-ns-extensible.js index 5bc9b868ca..28a628d211 100644 --- a/test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-extensible.js +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-extensible.js @@ -1,6 +1,6 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/imported-extensible.case -// - src/dynamic-import/module-namespace-object/promise.template +// - 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 @@ -72,8 +72,8 @@ info: | ---*/ -import('./module-code_FIXTURE.js').then(imported => { +import('./module-code_FIXTURE.js').then(ns => { - assert.sameValue(Object.isExtensible(imported), false); + assert.sameValue(Object.isExtensible(ns), 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/ns/promise-then-ns-no-iterator.js similarity index 93% rename from test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-no-iterator.js rename to test/language/module-code/dynamic-import/ns/promise-then-ns-no-iterator.js index e0d739dfc8..d8e507273b 100644 --- a/test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-no-iterator.js +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-no-iterator.js @@ -1,6 +1,6 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/imported-no-iterator.case -// - src/dynamic-import/module-namespace-object/promise.template +// - 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 @@ -71,8 +71,8 @@ info: | ---*/ -import('./module-code_FIXTURE.js').then(imported => { +import('./module-code_FIXTURE.js').then(ns => { - assert.sameValue(Object.prototype.hasOwnProperty.call(imported, Symbol.iterator), false); + assert.sameValue(Object.prototype.hasOwnProperty.call(ns, 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/ns/promise-then-ns-prop-descs.js similarity index 93% rename from test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-prop-descs.js rename to test/language/module-code/dynamic-import/ns/promise-then-ns-prop-descs.js index 9299fdae37..e8785d32ee 100644 --- a/test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-prop-descs.js +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-prop-descs.js @@ -1,6 +1,6 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/imported-prop-descs.case -// - src/dynamic-import/module-namespace-object/promise.template +// - 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 @@ -71,27 +71,27 @@ info: | ---*/ -import('./module-code_FIXTURE.js').then(imported => { +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(imported, 'default'); +var desc = Object.getOwnPropertyDescriptor(ns, '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'); +desc = Object.getOwnPropertyDescriptor(ns, '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'); +desc = Object.getOwnPropertyDescriptor(ns, 'z'); assert.sameValue(desc.value, 42, 'z value is 42'); assert.sameValue(desc.enumerable, true, 'z reports as enumerable'); diff --git a/test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-prototype.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-prototype.js similarity index 93% rename from test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-prototype.js rename to test/language/module-code/dynamic-import/ns/promise-then-ns-prototype.js index e5a1a00f68..8b636c3c2a 100644 --- a/test/language/module-code/dynamic-import/module-namespace-object/promise-then-imported-prototype.js +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-prototype.js @@ -1,6 +1,6 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/imported-prototype.case -// - src/dynamic-import/module-namespace-object/promise.template +// - 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 @@ -71,8 +71,8 @@ info: | ---*/ -import('./module-code_FIXTURE.js').then(imported => { +import('./module-code_FIXTURE.js').then(ns => { - assert.sameValue(Object.getPrototypeOf(imported), null, 'prototype is null'); + assert.sameValue(Object.getPrototypeOf(ns), null, 'prototype is null'); }).then($DONE, $DONE).catch($DONE); From 3968c2d83121de718bccbb288d38c0dcd497f466 Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Thu, 11 Oct 2018 09:49:08 -0400 Subject: [PATCH 08/14] Migrate test for ns --- .../ns-define-own-property.case | 114 ++++++++++++++++++ .../ns-delete-exported-init-no-strict.case | 41 +++++++ .../ns-delete-exported-init-strict.case | 47 ++++++++ .../ns-delete-non-exported-no-strict.case | 37 ++++++ .../ns-delete-non-exported-strict.case | 37 ++++++ .../ns/define-own-property_FIXTURE.js | 7 ++ .../ns/delete-exported-init_FIXTURE.js | 7 ++ .../dynamic-import/ns/empty_FIXTURE.js | 2 + 8 files changed, 292 insertions(+) create mode 100644 src/dynamic-import/ns-define-own-property.case create mode 100644 src/dynamic-import/ns-delete-exported-init-no-strict.case create mode 100644 src/dynamic-import/ns-delete-exported-init-strict.case create mode 100644 src/dynamic-import/ns-delete-non-exported-no-strict.case create mode 100644 src/dynamic-import/ns-delete-non-exported-strict.case create mode 100644 test/language/module-code/dynamic-import/ns/define-own-property_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/ns/delete-exported-init_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/ns/empty_FIXTURE.js 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 0000000000..2e909bc67f --- /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 0000000000..f004fd78e0 --- /dev/null +++ b/src/dynamic-import/ns-delete-exported-init-no-strict.case @@ -0,0 +1,41 @@ +// 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('./delete-exported-init_FIXTURE.js') +//- body +assert.sameValue(delete ns.local1, false, 'delete: local1'); +assert.sameValue( + Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1' +); +assert.sameValue(ns.local1, 333, '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, 444, '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, 333, '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 0000000000..9313542718 --- /dev/null +++ b/src/dynamic-import/ns-delete-exported-init-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 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('./delete-exported-init_FIXTURE.js') +//- body +assert.throws(TypeError, function() { + delete ns.local1; +}, 'delete: local1'); +assert.sameValue( + Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1' +); +assert.sameValue(ns.local1, 333, '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, 444, '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, 333, '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 0000000000..d7efe56594 --- /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 0000000000..0a819b800b --- /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/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 0000000000..050f79c1d1 --- /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/delete-exported-init_FIXTURE.js b/test/language/module-code/dynamic-import/ns/delete-exported-init_FIXTURE.js new file mode 100644 index 0000000000..29e539daa2 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/delete-exported-init_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 = 333; +var local2 = 444; +export { local2 as renamed }; +export { local1 as indirect } from './delete-exported-init_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 0000000000..96a3b85954 --- /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. From cce2f219f0a1237eefe3ee3e91a6461d8503484c Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Fri, 12 Oct 2018 13:51:09 -0400 Subject: [PATCH 09/14] Add tests for export * as ns from mod to dyn imports --- .../ns-get-nested-namespace-dflt-direct.case | 60 ++++++++++++++++++ ...ns-get-nested-namespace-dflt-indirect.case | 61 +++++++++++++++++++ .../ns-get-nested-namespace-props-nrml.case | 58 ++++++++++++++++++ ...d-namespace-dflt-skip-named-end_FIXTURE.js | 6 ++ ...ested-namespace-dflt-skip-named_FIXTURE.js | 4 ++ ...ed-namespace-dflt-skip-prod-end_FIXTURE.js | 5 ++ ...nested-namespace-dflt-skip-prod_FIXTURE.js | 4 ++ ...t-nested-namespace-props-nrml-1_FIXTURE.js | 4 ++ ...t-nested-namespace-props-nrml-2_FIXTURE.js | 23 +++++++ ...t-nested-namespace-props-nrml-3_FIXTURE.js | 5 ++ 10 files changed, 230 insertions(+) create mode 100644 src/dynamic-import/ns-get-nested-namespace-dflt-direct.case create mode 100644 src/dynamic-import/ns-get-nested-namespace-dflt-indirect.case create mode 100644 src/dynamic-import/ns-get-nested-namespace-props-nrml.case create mode 100644 test/language/module-code/dynamic-import/ns/get-nested-namespace-dflt-skip-named-end_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/ns/get-nested-namespace-dflt-skip-named_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/ns/get-nested-namespace-dflt-skip-prod-end_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/ns/get-nested-namespace-dflt-skip-prod_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/ns/get-nested-namespace-props-nrml-1_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/ns/get-nested-namespace-props-nrml-2_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/ns/get-nested-namespace-props-nrml-3_FIXTURE.js 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 0000000000..f8c524f348 --- /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 0000000000..f928107162 --- /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 0000000000..16ed8ef6f9 --- /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/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 0000000000..510e2b6642 --- /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 0000000000..fbd2343b7a --- /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 0000000000..3343f91a54 --- /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 0000000000..a626c903ab --- /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 0000000000..c3b3ea40c5 --- /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 0000000000..8e3281868d --- /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 0000000000..0c1192c1ad --- /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; From 1eb6c6a546b2c2863bcfa4fa7abd0ecdda728302 Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Fri, 12 Oct 2018 14:41:29 -0400 Subject: [PATCH 10/14] Generate tests --- .../ns/await-ns-define-own-property.js | 177 ++++++++++++++++++ ...await-ns-delete-exported-init-no-strict.js | 106 +++++++++++ .../await-ns-delete-exported-init-strict.js | 112 +++++++++++ .../await-ns-delete-non-exported-no-strict.js | 104 ++++++++++ .../ns/await-ns-delete-non-exported-strict.js | 104 ++++++++++ ...ait-ns-get-nested-namespace-dflt-direct.js | 126 +++++++++++++ ...t-ns-get-nested-namespace-dflt-indirect.js | 126 +++++++++++++ ...wait-ns-get-nested-namespace-props-nrml.js | 123 ++++++++++++ .../ns/promise-then-ns-define-own-property.js | 175 +++++++++++++++++ ...-then-ns-delete-exported-init-no-strict.js | 104 ++++++++++ ...ise-then-ns-delete-exported-init-strict.js | 110 +++++++++++ ...e-then-ns-delete-non-exported-no-strict.js | 102 ++++++++++ ...mise-then-ns-delete-non-exported-strict.js | 102 ++++++++++ ...hen-ns-get-nested-namespace-dflt-direct.js | 124 ++++++++++++ ...n-ns-get-nested-namespace-dflt-indirect.js | 124 ++++++++++++ ...then-ns-get-nested-namespace-props-nrml.js | 121 ++++++++++++ 16 files changed, 1940 insertions(+) create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-define-own-property.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-delete-exported-init-no-strict.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-delete-exported-init-strict.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-delete-non-exported-no-strict.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-delete-non-exported-strict.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-get-nested-namespace-dflt-direct.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-get-nested-namespace-dflt-indirect.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-get-nested-namespace-props-nrml.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-define-own-property.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-delete-exported-init-no-strict.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-delete-exported-init-strict.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-delete-non-exported-no-strict.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-delete-non-exported-strict.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-get-nested-namespace-dflt-direct.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-get-nested-namespace-dflt-indirect.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-get-nested-namespace-props-nrml.js 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 0000000000..62f67ee2ee --- /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 0000000000..5179496733 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-delete-exported-init-no-strict.js @@ -0,0 +1,106 @@ +// 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('./delete-exported-init_FIXTURE.js'); + + assert.sameValue(delete ns.local1, false, 'delete: local1'); + assert.sameValue( + Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1' + ); + assert.sameValue(ns.local1, 333, '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, 444, '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, 333, '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 0000000000..6b81d20282 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-delete-exported-init-strict.js @@ -0,0 +1,112 @@ +// 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('./delete-exported-init_FIXTURE.js'); + + assert.throws(TypeError, function() { + delete ns.local1; + }, 'delete: local1'); + assert.sameValue( + Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1' + ); + assert.sameValue(ns.local1, 333, '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, 444, '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, 333, '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 0000000000..c695bbfff2 --- /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 0000000000..6d46175991 --- /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-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 0000000000..52656a88ce --- /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 0000000000..01a995135e --- /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 0000000000..c19ba12a3c --- /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/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 0000000000..e746ede5a8 --- /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 0000000000..41d13495bf --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-exported-init-no-strict.js @@ -0,0 +1,104 @@ +// 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('./delete-exported-init_FIXTURE.js').then(ns => { + + assert.sameValue(delete ns.local1, false, 'delete: local1'); + assert.sameValue( + Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1' + ); + assert.sameValue(ns.local1, 333, '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, 444, '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, 333, '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 0000000000..c07c9e9c18 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-exported-init-strict.js @@ -0,0 +1,110 @@ +// 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('./delete-exported-init_FIXTURE.js').then(ns => { + + assert.throws(TypeError, function() { + delete ns.local1; + }, 'delete: local1'); + assert.sameValue( + Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1' + ); + assert.sameValue(ns.local1, 333, '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, 444, '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, 333, '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 0000000000..88b707c8d0 --- /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 0000000000..700ee431f8 --- /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-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 0000000000..2125506f3d --- /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 0000000000..a505ba70e6 --- /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 0000000000..7dfe3eadef --- /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); From b7e0a48725ab6ec181e5ae0660db3d901122c1ee Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Fri, 12 Oct 2018 15:32:38 -0400 Subject: [PATCH 11/14] Reuse fixture --- .../ns-delete-exported-init-no-strict.case | 14 +++++-- .../ns-delete-exported-init-strict.case | 16 ++++++-- src/dynamic-import/ns-prop-descs.case | 37 ++++++++++++------- .../ns/delete-exported-init_FIXTURE.js | 7 ---- .../dynamic-import/ns/module-code_FIXTURE.js | 10 +++-- 5 files changed, 51 insertions(+), 33 deletions(-) delete mode 100644 test/language/module-code/dynamic-import/ns/delete-exported-init_FIXTURE.js diff --git a/src/dynamic-import/ns-delete-exported-init-no-strict.case b/src/dynamic-import/ns-delete-exported-init-no-strict.case index f004fd78e0..e0aaeac845 100644 --- a/src/dynamic-import/ns-delete-exported-init-no-strict.case +++ b/src/dynamic-import/ns-delete-exported-init-no-strict.case @@ -18,19 +18,25 @@ flags: [noStrict] ---*/ //- import -import('./delete-exported-init_FIXTURE.js') +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, 333, 'binding unmodified: 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, 444, 'binding unmodified: renamed'); +assert.sameValue(ns.renamed, 'TC39', 'binding unmodified: renamed'); assert.sameValue(delete ns.indirect, false, 'delete: indirect'); assert.sameValue( @@ -38,4 +44,4 @@ assert.sameValue( false, 'Reflect.deleteProperty: indirect' ); -assert.sameValue(ns.indirect, 333, 'binding unmodified: 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 index 9313542718..a4b4f0a9d4 100644 --- a/src/dynamic-import/ns-delete-exported-init-strict.case +++ b/src/dynamic-import/ns-delete-exported-init-strict.case @@ -18,15 +18,23 @@ flags: [onlyStrict] ---*/ //- import -import('./delete-exported-init_FIXTURE.js') +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, 333, 'binding unmodified: local1'); +assert.sameValue(ns.local1, 'Test262', 'binding unmodified: local1'); assert.throws(TypeError, function() { delete ns.renamed; @@ -34,7 +42,7 @@ assert.throws(TypeError, function() { assert.sameValue( Reflect.deleteProperty(ns, 'renamed'), false, 'Reflect.deleteProperty: renamed' ); -assert.sameValue(ns.renamed, 444, 'binding unmodified: renamed'); +assert.sameValue(ns.renamed, 'TC39', 'binding unmodified: renamed'); assert.throws(TypeError, function() { delete ns.indirect; @@ -44,4 +52,4 @@ assert.sameValue( false, 'Reflect.deleteProperty: indirect' ); -assert.sameValue(ns.indirect, 333, 'binding unmodified: indirect'); +assert.sameValue(ns.indirect, 'Test262', 'binding unmodified: indirect'); diff --git a/src/dynamic-import/ns-prop-descs.case b/src/dynamic-import/ns-prop-descs.case index ad873e711d..8c9ef73dae 100644 --- a/src/dynamic-import/ns-prop-descs.case +++ b/src/dynamic-import/ns-prop-descs.case @@ -5,6 +5,8 @@ desc: imported object properties descriptors template: namespace ---*/ +// exports: default === 42, local1 === 'Test262', renamed === 'TC39', indirect === 'Test262' + //- import import('./module-code_FIXTURE.js') //- body @@ -14,21 +16,28 @@ import('./module-code_FIXTURE.js') // object does not. var desc = Object.getOwnPropertyDescriptor(ns, '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'); +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, 'x'); +desc = Object.getOwnPropertyDescriptor(ns, 'local1'); -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'); +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, 'z'); +desc = Object.getOwnPropertyDescriptor(ns, 'renamed'); -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'); +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/test/language/module-code/dynamic-import/ns/delete-exported-init_FIXTURE.js b/test/language/module-code/dynamic-import/ns/delete-exported-init_FIXTURE.js deleted file mode 100644 index 29e539daa2..0000000000 --- a/test/language/module-code/dynamic-import/ns/delete-exported-init_FIXTURE.js +++ /dev/null @@ -1,7 +0,0 @@ -// 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 = 333; -var local2 = 444; -export { local2 as renamed }; -export { local1 as indirect } from './delete-exported-init_FIXTURE.js'; 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 index 96b0503d95..62cb5ae821 100644 --- a/test/language/module-code/dynamic-import/ns/module-code_FIXTURE.js +++ b/test/language/module-code/dynamic-import/ns/module-code_FIXTURE.js @@ -1,8 +1,10 @@ // 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; +// exports: default === 42, local1 === 'Test262', renamed === 'TC39', indirect === 'Test262' -export default y; -export { x, y as z }; +export var local1 = 'Test262'; +var local2 = 'TC39'; +export { local2 as renamed }; +export { local1 as indirect } from './module-code_FIXTURE.js'; +export default 42; From 103ee25959dece8fc85f8c460962ee00aca2ba11 Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Fri, 12 Oct 2018 17:04:23 -0400 Subject: [PATCH 12/14] More coverage for namespace object --- .../ns-get-own-property-str-found-init.case | 58 +++++++++++++++++ .../ns-get-own-property-str-not-found.case | 51 +++++++++++++++ .../ns-get-own-property-sym.case | 31 +++++++++ src/dynamic-import/ns-get-str-found.case | 22 +++++++ src/dynamic-import/ns-get-str-not-found.case | 25 ++++++++ src/dynamic-import/ns-get-sym-found.case | 20 ++++++ src/dynamic-import/ns-get-sym-not-found.case | 20 ++++++ .../ns-has-property-str-found-init.case | 29 +++++++++ .../ns-has-property-str-not-found.case | 37 +++++++++++ .../ns-has-property-sym-found.case | 19 ++++++ .../ns-has-property-sym-not-found.case | 22 +++++++ .../ns-own-property-keys-sort.case | 64 +++++++++++++++++++ .../ns-prevent-extensions-object.case | 16 +++++ .../ns-prevent-extensions-reflect.case | 13 ++++ src/dynamic-import/ns-prop-descs.case | 4 +- src/dynamic-import/ns-prototype.case | 1 + src/dynamic-import/ns-set-no-strict.case | 43 +++++++++++++ .../ns-set-prototype-of-null.case | 16 +++++ src/dynamic-import/ns-set-prototype-of.case | 19 ++++++ .../ns-set-same-values-no-strict.case | 36 +++++++++++ .../ns-set-same-values-strict.case | 46 +++++++++++++ src/dynamic-import/ns-set-strict.case | 57 +++++++++++++++++ .../ns/own-keys-sort_FIXTURE.js | 17 +++++ 23 files changed, 663 insertions(+), 3 deletions(-) create mode 100644 src/dynamic-import/ns-get-own-property-str-found-init.case create mode 100644 src/dynamic-import/ns-get-own-property-str-not-found.case create mode 100644 src/dynamic-import/ns-get-own-property-sym.case create mode 100644 src/dynamic-import/ns-get-str-found.case create mode 100644 src/dynamic-import/ns-get-str-not-found.case create mode 100644 src/dynamic-import/ns-get-sym-found.case create mode 100644 src/dynamic-import/ns-get-sym-not-found.case create mode 100644 src/dynamic-import/ns-has-property-str-found-init.case create mode 100644 src/dynamic-import/ns-has-property-str-not-found.case create mode 100644 src/dynamic-import/ns-has-property-sym-found.case create mode 100644 src/dynamic-import/ns-has-property-sym-not-found.case create mode 100644 src/dynamic-import/ns-own-property-keys-sort.case create mode 100644 src/dynamic-import/ns-prevent-extensions-object.case create mode 100644 src/dynamic-import/ns-prevent-extensions-reflect.case create mode 100644 src/dynamic-import/ns-set-no-strict.case create mode 100644 src/dynamic-import/ns-set-prototype-of-null.case create mode 100644 src/dynamic-import/ns-set-prototype-of.case create mode 100644 src/dynamic-import/ns-set-same-values-no-strict.case create mode 100644 src/dynamic-import/ns-set-same-values-strict.case create mode 100644 src/dynamic-import/ns-set-strict.case create mode 100644 test/language/module-code/dynamic-import/ns/own-keys-sort_FIXTURE.js 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 0000000000..3d67db2bbc --- /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 0000000000..350aa00405 --- /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 0000000000..e84169d34b --- /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 0000000000..5f26725bc3 --- /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 0000000000..9cf702cdbf --- /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 0000000000..49f2daeb31 --- /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 0000000000..38e146f336 --- /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 0000000000..3a713efda1 --- /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 0000000000..5d64a62270 --- /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 0000000000..e3e8f33f05 --- /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 0000000000..5f1e050e42 --- /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-own-property-keys-sort.case b/src/dynamic-import/ns-own-property-keys-sort.case new file mode 100644 index 0000000000..b946b02af5 --- /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 0000000000..bd1053066d --- /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 0000000000..4b54b3fa13 --- /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 index 8c9ef73dae..9bb34d9d86 100644 --- a/src/dynamic-import/ns-prop-descs.case +++ b/src/dynamic-import/ns-prop-descs.case @@ -5,8 +5,6 @@ desc: imported object properties descriptors template: namespace ---*/ -// exports: default === 42, local1 === 'Test262', renamed === 'TC39', indirect === 'Test262' - //- import import('./module-code_FIXTURE.js') //- body @@ -35,7 +33,7 @@ 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:'); +desc = Object.getOwnPropertyDescriptor(ns, 'indirect'); assert.sameValue(desc.value, 'Test262', 'indirect: value is Test262"'); assert.sameValue(desc.enumerable, true, 'indirect: is enumerable'); diff --git a/src/dynamic-import/ns-prototype.case b/src/dynamic-import/ns-prototype.case index 3a8d66d41e..d10f33b6d7 100644 --- a/src/dynamic-import/ns-prototype.case +++ b/src/dynamic-import/ns-prototype.case @@ -8,4 +8,5 @@ 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 0000000000..842e8cac7d --- /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 0000000000..4ff4054909 --- /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 0000000000..c1926fa947 --- /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 0000000000..e8ed24ffb5 --- /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 0000000000..126ef0f95e --- /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 0000000000..136e6f79f0 --- /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/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 0000000000..53e5ea5a91 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/own-keys-sort_FIXTURE.js @@ -0,0 +1,17 @@ +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; From 81d6bb21a9510052b2e1cec0e1ec1b4c8c5dc974 Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Fri, 12 Oct 2018 17:27:24 -0400 Subject: [PATCH 13/14] Generate tests --- ...await-ns-delete-exported-init-no-strict.js | 14 +- .../await-ns-delete-exported-init-strict.js | 16 ++- ...wait-ns-get-own-property-str-found-init.js | 124 +++++++++++++++++ ...await-ns-get-own-property-str-not-found.js | 117 ++++++++++++++++ .../ns/await-ns-get-own-property-sym.js | 95 +++++++++++++ .../ns/await-ns-get-str-found.js | 88 ++++++++++++ .../ns/await-ns-get-str-not-found.js | 90 ++++++++++++ .../ns/await-ns-get-sym-found.js | 85 ++++++++++++ .../ns/await-ns-get-sym-not-found.js | 85 ++++++++++++ .../await-ns-has-property-str-found-init.js | 95 +++++++++++++ .../ns/await-ns-has-property-str-not-found.js | 102 ++++++++++++++ .../ns/await-ns-has-property-sym-found.js | 84 +++++++++++ .../ns/await-ns-has-property-sym-not-found.js | 86 ++++++++++++ .../ns/await-ns-own-property-keys-sort.js | 130 ++++++++++++++++++ .../ns/await-ns-prevent-extensions-object.js | 83 +++++++++++ .../ns/await-ns-prevent-extensions-reflect.js | 80 +++++++++++ .../dynamic-import/ns/await-ns-prop-descs.js | 35 +++-- .../dynamic-import/ns/await-ns-prototype.js | 1 + .../ns/await-ns-set-no-strict.js | 108 +++++++++++++++ .../ns/await-ns-set-prototype-of-null.js | 81 +++++++++++ .../ns/await-ns-set-prototype-of.js | 86 ++++++++++++ .../ns/await-ns-set-same-values-no-strict.js | 100 ++++++++++++++ .../ns/await-ns-set-same-values-strict.js | 110 +++++++++++++++ .../dynamic-import/ns/await-ns-set-strict.js | 122 ++++++++++++++++ ...-then-ns-delete-exported-init-no-strict.js | 14 +- ...ise-then-ns-delete-exported-init-strict.js | 16 ++- ...then-ns-get-own-property-str-found-init.js | 122 ++++++++++++++++ ...-then-ns-get-own-property-str-not-found.js | 115 ++++++++++++++++ .../promise-then-ns-get-own-property-sym.js | 93 +++++++++++++ .../ns/promise-then-ns-get-str-found.js | 86 ++++++++++++ .../ns/promise-then-ns-get-str-not-found.js | 88 ++++++++++++ .../ns/promise-then-ns-get-sym-found.js | 83 +++++++++++ .../ns/promise-then-ns-get-sym-not-found.js | 83 +++++++++++ ...ise-then-ns-has-property-str-found-init.js | 93 +++++++++++++ ...mise-then-ns-has-property-str-not-found.js | 100 ++++++++++++++ .../promise-then-ns-has-property-sym-found.js | 82 +++++++++++ ...mise-then-ns-has-property-sym-not-found.js | 84 +++++++++++ .../promise-then-ns-own-property-keys-sort.js | 128 +++++++++++++++++ ...omise-then-ns-prevent-extensions-object.js | 81 +++++++++++ ...mise-then-ns-prevent-extensions-reflect.js | 78 +++++++++++ .../ns/promise-then-ns-prop-descs.js | 35 +++-- .../ns/promise-then-ns-prototype.js | 1 + .../ns/promise-then-ns-set-no-strict.js | 106 ++++++++++++++ .../promise-then-ns-set-prototype-of-null.js | 79 +++++++++++ .../ns/promise-then-ns-set-prototype-of.js | 84 +++++++++++ ...omise-then-ns-set-same-values-no-strict.js | 98 +++++++++++++ .../promise-then-ns-set-same-values-strict.js | 108 +++++++++++++++ .../ns/promise-then-ns-set-strict.js | 120 ++++++++++++++++ 48 files changed, 3950 insertions(+), 44 deletions(-) create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-get-own-property-str-found-init.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-get-own-property-str-not-found.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-get-own-property-sym.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-get-str-found.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-get-str-not-found.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-get-sym-found.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-get-sym-not-found.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-has-property-str-found-init.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-has-property-str-not-found.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-has-property-sym-found.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-has-property-sym-not-found.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-own-property-keys-sort.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-prevent-extensions-object.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-prevent-extensions-reflect.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-set-no-strict.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-set-prototype-of-null.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-set-prototype-of.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-set-same-values-no-strict.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-set-same-values-strict.js create mode 100644 test/language/module-code/dynamic-import/ns/await-ns-set-strict.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-get-own-property-str-found-init.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-get-own-property-str-not-found.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-get-own-property-sym.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-get-str-found.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-get-str-not-found.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-get-sym-found.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-get-sym-not-found.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-str-found-init.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-str-not-found.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-sym-found.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-sym-not-found.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-own-property-keys-sort.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-prevent-extensions-object.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-prevent-extensions-reflect.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-set-no-strict.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-set-prototype-of-null.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-set-prototype-of.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-set-same-values-no-strict.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-set-same-values-strict.js create mode 100644 test/language/module-code/dynamic-import/ns/promise-then-ns-set-strict.js 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 index 5179496733..3daa25f30e 100644 --- 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 @@ -80,19 +80,25 @@ info: | ---*/ async function fn() { - const ns = await import('./delete-exported-init_FIXTURE.js'); + 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, 333, 'binding unmodified: 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, 444, 'binding unmodified: renamed'); + assert.sameValue(ns.renamed, 'TC39', 'binding unmodified: renamed'); assert.sameValue(delete ns.indirect, false, 'delete: indirect'); assert.sameValue( @@ -100,7 +106,7 @@ async function fn() { false, 'Reflect.deleteProperty: indirect' ); - assert.sameValue(ns.indirect, 333, 'binding unmodified: 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 index 6b81d20282..9a93989c80 100644 --- 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 @@ -80,7 +80,15 @@ info: | ---*/ async function fn() { - const ns = await import('./delete-exported-init_FIXTURE.js'); + 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; @@ -88,7 +96,7 @@ async function fn() { assert.sameValue( Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1' ); - assert.sameValue(ns.local1, 333, 'binding unmodified: local1'); + assert.sameValue(ns.local1, 'Test262', 'binding unmodified: local1'); assert.throws(TypeError, function() { delete ns.renamed; @@ -96,7 +104,7 @@ async function fn() { assert.sameValue( Reflect.deleteProperty(ns, 'renamed'), false, 'Reflect.deleteProperty: renamed' ); - assert.sameValue(ns.renamed, 444, 'binding unmodified: renamed'); + assert.sameValue(ns.renamed, 'TC39', 'binding unmodified: renamed'); assert.throws(TypeError, function() { delete ns.indirect; @@ -106,7 +114,7 @@ async function fn() { false, 'Reflect.deleteProperty: indirect' ); - assert.sameValue(ns.indirect, 333, 'binding unmodified: 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-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 0000000000..0577d03135 --- /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 0000000000..abf689fcfe --- /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 0000000000..318788e28b --- /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 0000000000..0a971a6944 --- /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 0000000000..4c15994aee --- /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 0000000000..da8c6c2797 --- /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 0000000000..3366101da4 --- /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 0000000000..7e12f8b083 --- /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 0000000000..7d241a47a0 --- /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 0000000000..1e68c121ca --- /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 0000000000..fddf13b985 --- /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-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 0000000000..b4487e09d1 --- /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 0000000000..7fc2708a5d --- /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 0000000000..28edbf8fca --- /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 index 3d0d29471a..99362a9282 100644 --- 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 @@ -80,24 +80,31 @@ async function fn() { // object does not. var desc = Object.getOwnPropertyDescriptor(ns, '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'); +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, 'x'); +desc = Object.getOwnPropertyDescriptor(ns, 'local1'); -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'); +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, 'z'); +desc = Object.getOwnPropertyDescriptor(ns, 'renamed'); -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'); +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 index 4bbd93bbad..c21c6b84fb 100644 --- a/test/language/module-code/dynamic-import/ns/await-ns-prototype.js +++ b/test/language/module-code/dynamic-import/ns/await-ns-prototype.js @@ -74,6 +74,7 @@ info: | 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'); } 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 0000000000..858c0275ba --- /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 0000000000..02a75f470a --- /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 0000000000..819f8429cd --- /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 0000000000..e5e636b0c9 --- /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 0000000000..c08d85d95c --- /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 0000000000..31eda654d5 --- /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/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 index 41d13495bf..39847dde75 100644 --- 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 @@ -79,19 +79,25 @@ info: | ---*/ -import('./delete-exported-init_FIXTURE.js').then(ns => { +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, 333, 'binding unmodified: 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, 444, 'binding unmodified: renamed'); + assert.sameValue(ns.renamed, 'TC39', 'binding unmodified: renamed'); assert.sameValue(delete ns.indirect, false, 'delete: indirect'); assert.sameValue( @@ -99,6 +105,6 @@ import('./delete-exported-init_FIXTURE.js').then(ns => { false, 'Reflect.deleteProperty: indirect' ); - assert.sameValue(ns.indirect, 333, 'binding unmodified: 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 index c07c9e9c18..c8fad64d43 100644 --- 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 @@ -79,7 +79,15 @@ info: | ---*/ -import('./delete-exported-init_FIXTURE.js').then(ns => { +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; @@ -87,7 +95,7 @@ import('./delete-exported-init_FIXTURE.js').then(ns => { assert.sameValue( Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1' ); - assert.sameValue(ns.local1, 333, 'binding unmodified: local1'); + assert.sameValue(ns.local1, 'Test262', 'binding unmodified: local1'); assert.throws(TypeError, function() { delete ns.renamed; @@ -95,7 +103,7 @@ import('./delete-exported-init_FIXTURE.js').then(ns => { assert.sameValue( Reflect.deleteProperty(ns, 'renamed'), false, 'Reflect.deleteProperty: renamed' ); - assert.sameValue(ns.renamed, 444, 'binding unmodified: renamed'); + assert.sameValue(ns.renamed, 'TC39', 'binding unmodified: renamed'); assert.throws(TypeError, function() { delete ns.indirect; @@ -105,6 +113,6 @@ import('./delete-exported-init_FIXTURE.js').then(ns => { false, 'Reflect.deleteProperty: indirect' ); - assert.sameValue(ns.indirect, 333, 'binding unmodified: 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-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 0000000000..5652eef119 --- /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 0000000000..7e3e40c2d8 --- /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 0000000000..6824a10f98 --- /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 0000000000..7322efc541 --- /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 0000000000..bae537b0d5 --- /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 0000000000..f2f4e20cfb --- /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 0000000000..d34090ff6b --- /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 0000000000..b142bc0aff --- /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 0000000000..acaef1dd02 --- /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 0000000000..890a6127b1 --- /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 0000000000..d737f6a66b --- /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-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 0000000000..d773959f10 --- /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 0000000000..0210353312 --- /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 0000000000..8860abb4a3 --- /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 index e8785d32ee..dbd285644d 100644 --- 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 @@ -79,23 +79,30 @@ import('./module-code_FIXTURE.js').then(ns => { // object does not. var desc = Object.getOwnPropertyDescriptor(ns, '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'); +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, 'x'); +desc = Object.getOwnPropertyDescriptor(ns, 'local1'); -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'); +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, 'z'); +desc = Object.getOwnPropertyDescriptor(ns, 'renamed'); -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'); +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 index 8b636c3c2a..5af5a859d3 100644 --- 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 @@ -73,6 +73,7 @@ info: | 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 0000000000..759385ffed --- /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 0000000000..95e9e8b15a --- /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 0000000000..9636c173e8 --- /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 0000000000..63d1246935 --- /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 0000000000..edbc50d19b --- /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 0000000000..4518fc4d3e --- /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); From 206370b98e59c8fa056fff071a49c6c3492f7d84 Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Fri, 12 Oct 2018 17:58:54 -0400 Subject: [PATCH 14/14] missing copyright header --- .../module-code/dynamic-import/ns/own-keys-sort_FIXTURE.js | 3 +++ 1 file changed, 3 insertions(+) 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 index 53e5ea5a91..baa8645460 100644 --- 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 @@ -1,3 +1,6 @@ +// 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 };