diff --git a/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-eval-rqstd-abrupt-typeerror.js b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-eval-rqstd-abrupt-typeerror.js new file mode 100644 index 0000000000000000000000000000000000000000..03f0780f476d69107e1b51aae43a4895843213f8 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-eval-rqstd-abrupt-typeerror.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-rqstd-abrupt-typeerror.case +// - src/dynamic-import/catch/nested-async-arrow-fn-await.template +/*--- +description: Abrupt completion during module evaluation precludes further evaluation (nested in async arrow 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]]. + + + [...] + 6. For each String required that is an element of + module.[[RequestedModules]] do, + a. Let requiredModule be ? HostResolveImportedModule(module, required). + b. Perform ? requiredModule.ModuleEvaluation(). + +---*/ + +const f = async () => { + await import('./eval-rqstd-abrupt-err-type_FIXTURE.js'); +} + +f().catch(error => { + + assert.sameValue(error.name, 'TypeError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-eval-rqstd-abrupt-urierror.js b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-eval-rqstd-abrupt-urierror.js new file mode 100644 index 0000000000000000000000000000000000000000..398935712cb97b7098aa6db06574e324341de168 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-eval-rqstd-abrupt-urierror.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-rqstd-abrupt-urierror.case +// - src/dynamic-import/catch/nested-async-arrow-fn-await.template +/*--- +description: Abrupt completion during module evaluation precludes further evaluation (nested in async arrow 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]]. + + + [...] + 6. For each String required that is an element of + module.[[RequestedModules]] do, + a. Let requiredModule be ? HostResolveImportedModule(module, required). + b. Perform ? requiredModule.ModuleEvaluation(). + +---*/ + +const f = async () => { + await import('./eval-rqstd-abrupt-err-uri_FIXTURE.js'); +} + +f().catch(error => { + + assert.sameValue(error.name, 'URIError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-eval-script-code-target.js new file mode 100644 index 0000000000000000000000000000000000000000..ca460e1b977238853282782b89fcab19f34eb667 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-arrow-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-arrow-fn-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 arrow 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. + +---*/ + +const f = async () => { + await import('./script-code_FIXTURE.js'); +} + +f().catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-file-does-not-exist.js b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-file-does-not-exist.js new file mode 100644 index 0000000000000000000000000000000000000000..7f373e27bc1d4d645111e0bf0c13ba3e7baf70df --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-file-does-not-exist.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/file-does-not-exist.case +// - src/dynamic-import/catch/nested-async-arrow-fn-await.template +/*--- +description: Non existent file can't resolve to a Script or Module Record (nested in async arrow 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]]. + + + If a Module Record corresponding to the pair referencingModulereferencingScriptOrModule, + specifier does not exist or cannot be created, an exception must be thrown. + +---*/ + +const f = async () => { + await import('./THIS_FILE_DOES_NOT_EXIST.js'); +} + +f().catch(error => { + + assert.notSameValue(typeof error, 'undefined'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-instn-iee-err-ambiguous-import.js b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-instn-iee-err-ambiguous-import.js new file mode 100644 index 0000000000000000000000000000000000000000..ef8f81e16102d2c7836055ea3d6a55f7e71008ad --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-instn-iee-err-ambiguous-import.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/instn-iee-err-ambiguous-import.case +// - src/dynamic-import/catch/nested-async-arrow-fn-await.template +/*--- +description: IndirectExportEntries validation - ambiguous imported bindings (nested in async arrow 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]]. + + + [...] + 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". + +---*/ + +const f = async () => { + await import('./instn-iee-err-ambiguous-export_FIXTURE.js'); +} + +f().catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-instn-iee-err-circular.js b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-instn-iee-err-circular.js new file mode 100644 index 0000000000000000000000000000000000000000..b5c8b1dd114e8d7225f4e23398ea189a3874435f --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-instn-iee-err-circular.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/instn-iee-err-circular.case +// - src/dynamic-import/catch/nested-async-arrow-fn-await.template +/*--- +description: IndirectExportEntries validation - circular imported bindings (nested in async arrow 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]]. + + + [...] + 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. + +---*/ + +const f = async () => { + await import('./instn-iee-err-circular-1_FIXTURE.js'); +} + +f().catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000000000000000000000000000000000..416932c3f30cff8b469b900d88ec6dbcd1703d06 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-arrow-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-arrow-fn-await.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested in async arrow 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'; + } +}; + + +const f = async () => { + await import(obj); +} + +f().catch(error => { + + assert.sameValue(error, 'custom error'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-eval-rqstd-abrupt-typeerror.js b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-eval-rqstd-abrupt-typeerror.js new file mode 100644 index 0000000000000000000000000000000000000000..9578a8602755d4d7c0fd58afc9b048aa590c21ca --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-eval-rqstd-abrupt-typeerror.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-rqstd-abrupt-typeerror.case +// - src/dynamic-import/catch/nested-async-arrow-fn-return-await.template +/*--- +description: Abrupt completion during module evaluation precludes further evaluation (nested in async arrow function, returned) +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]]. + + + [...] + 6. For each String required that is an element of + module.[[RequestedModules]] do, + a. Let requiredModule be ? HostResolveImportedModule(module, required). + b. Perform ? requiredModule.ModuleEvaluation(). + +---*/ + +const f = async () => await import('./eval-rqstd-abrupt-err-type_FIXTURE.js'); + +f().catch(error => { + + assert.sameValue(error.name, 'TypeError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-eval-rqstd-abrupt-urierror.js b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-eval-rqstd-abrupt-urierror.js new file mode 100644 index 0000000000000000000000000000000000000000..c336582f108707838d91cb156d0f72ca0b206380 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-eval-rqstd-abrupt-urierror.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-rqstd-abrupt-urierror.case +// - src/dynamic-import/catch/nested-async-arrow-fn-return-await.template +/*--- +description: Abrupt completion during module evaluation precludes further evaluation (nested in async arrow function, returned) +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]]. + + + [...] + 6. For each String required that is an element of + module.[[RequestedModules]] do, + a. Let requiredModule be ? HostResolveImportedModule(module, required). + b. Perform ? requiredModule.ModuleEvaluation(). + +---*/ + +const f = async () => await import('./eval-rqstd-abrupt-err-uri_FIXTURE.js'); + +f().catch(error => { + + assert.sameValue(error.name, 'URIError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-eval-script-code-target.js new file mode 100644 index 0000000000000000000000000000000000000000..4b9c53abdc612d927cf8daadb77be75bc580e58d --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-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-async-arrow-fn-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 arrow function, returned) +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. + +---*/ + +const f = async () => await import('./script-code_FIXTURE.js'); + +f().catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-file-does-not-exist.js b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-file-does-not-exist.js new file mode 100644 index 0000000000000000000000000000000000000000..a6128b230bc7776128994ac3be515f65d6fb27a4 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-file-does-not-exist.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/file-does-not-exist.case +// - src/dynamic-import/catch/nested-async-arrow-fn-return-await.template +/*--- +description: Non existent file can't resolve to a Script or Module Record (nested in async arrow function, returned) +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]]. + + + If a Module Record corresponding to the pair referencingModulereferencingScriptOrModule, + specifier does not exist or cannot be created, an exception must be thrown. + +---*/ + +const f = async () => await import('./THIS_FILE_DOES_NOT_EXIST.js'); + +f().catch(error => { + + assert.notSameValue(typeof error, 'undefined'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-instn-iee-err-ambiguous-import.js b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-instn-iee-err-ambiguous-import.js new file mode 100644 index 0000000000000000000000000000000000000000..f7ae233728d76fcd0dc3853179b4de86b06310d1 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-instn-iee-err-ambiguous-import.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/instn-iee-err-ambiguous-import.case +// - src/dynamic-import/catch/nested-async-arrow-fn-return-await.template +/*--- +description: IndirectExportEntries validation - ambiguous imported bindings (nested in async arrow function, returned) +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]]. + + + [...] + 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". + +---*/ + +const f = async () => await import('./instn-iee-err-ambiguous-export_FIXTURE.js'); + +f().catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-instn-iee-err-circular.js b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-instn-iee-err-circular.js new file mode 100644 index 0000000000000000000000000000000000000000..634db6b198ddb496cf6b09112aadc49578bc6a48 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-instn-iee-err-circular.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/instn-iee-err-circular.case +// - src/dynamic-import/catch/nested-async-arrow-fn-return-await.template +/*--- +description: IndirectExportEntries validation - circular imported bindings (nested in async arrow function, returned) +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]]. + + + [...] + 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. + +---*/ + +const f = async () => await import('./instn-iee-err-circular-1_FIXTURE.js'); + +f().catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000000000000000000000000000000000..35c45d55f0d13426b7f416435d1162ff04151a6f --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-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-async-arrow-fn-return-await.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested in async arrow function, returned) +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'; + } +}; + + +const f = async () => await import(obj); + +f().catch(error => { + + assert.sameValue(error, 'custom error'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-gen-await-eval-rqstd-abrupt-typeerror.js b/test/language/module-code/dynamic-import/catch/nested-async-gen-await-eval-rqstd-abrupt-typeerror.js new file mode 100644 index 0000000000000000000000000000000000000000..eca64bb0fbbc3d689db9a4ca7d9fe26acabcfce0 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-gen-await-eval-rqstd-abrupt-typeerror.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-rqstd-abrupt-typeerror.case +// - src/dynamic-import/catch/nested-async-generator-await.template +/*--- +description: Abrupt completion during module evaluation precludes further evaluation (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async-iteration] +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]]. + + + [...] + 6. For each String required that is an element of + module.[[RequestedModules]] do, + a. Let requiredModule be ? HostResolveImportedModule(module, required). + b. Perform ? requiredModule.ModuleEvaluation(). + +---*/ + +async function * f() { + await import('./eval-rqstd-abrupt-err-type_FIXTURE.js'); +} + +f().next().catch(error => { + + assert.sameValue(error.name, 'TypeError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-gen-await-eval-rqstd-abrupt-urierror.js b/test/language/module-code/dynamic-import/catch/nested-async-gen-await-eval-rqstd-abrupt-urierror.js new file mode 100644 index 0000000000000000000000000000000000000000..5955e4f28c8f2c94ee004547983cb0dd34743627 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-gen-await-eval-rqstd-abrupt-urierror.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-rqstd-abrupt-urierror.case +// - src/dynamic-import/catch/nested-async-generator-await.template +/*--- +description: Abrupt completion during module evaluation precludes further evaluation (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async-iteration] +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]]. + + + [...] + 6. For each String required that is an element of + module.[[RequestedModules]] do, + a. Let requiredModule be ? HostResolveImportedModule(module, required). + b. Perform ? requiredModule.ModuleEvaluation(). + +---*/ + +async function * f() { + await import('./eval-rqstd-abrupt-err-uri_FIXTURE.js'); +} + +f().next().catch(error => { + + assert.sameValue(error.name, 'URIError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-gen-await-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-async-gen-await-eval-script-code-target.js new file mode 100644 index 0000000000000000000000000000000000000000..2ac7d212c359579d656a85ca04e656b0a2a4dd46 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-gen-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-generator-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 generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async-iteration] +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'); +} + +f().next().catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-gen-await-file-does-not-exist.js b/test/language/module-code/dynamic-import/catch/nested-async-gen-await-file-does-not-exist.js new file mode 100644 index 0000000000000000000000000000000000000000..07fb2ca3cbb6d0e84994c174f30912c34cc2a3e7 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-gen-await-file-does-not-exist.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/file-does-not-exist.case +// - src/dynamic-import/catch/nested-async-generator-await.template +/*--- +description: Non existent file can't resolve to a Script or Module Record (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async-iteration] +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]]. + + + If a Module Record corresponding to the pair referencingModulereferencingScriptOrModule, + specifier does not exist or cannot be created, an exception must be thrown. + +---*/ + +async function * f() { + await import('./THIS_FILE_DOES_NOT_EXIST.js'); +} + +f().next().catch(error => { + + assert.notSameValue(typeof error, 'undefined'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-gen-await-instn-iee-err-ambiguous-import.js b/test/language/module-code/dynamic-import/catch/nested-async-gen-await-instn-iee-err-ambiguous-import.js new file mode 100644 index 0000000000000000000000000000000000000000..75e04b0c28f0434487626b84c49cf8c80808de9b --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-gen-await-instn-iee-err-ambiguous-import.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/instn-iee-err-ambiguous-import.case +// - src/dynamic-import/catch/nested-async-generator-await.template +/*--- +description: IndirectExportEntries validation - ambiguous imported bindings (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async-iteration] +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]]. + + + [...] + 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". + +---*/ + +async function * f() { + await import('./instn-iee-err-ambiguous-export_FIXTURE.js'); +} + +f().next().catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-gen-await-instn-iee-err-circular.js b/test/language/module-code/dynamic-import/catch/nested-async-gen-await-instn-iee-err-circular.js new file mode 100644 index 0000000000000000000000000000000000000000..a47d46a3044b9f2c2592bcdf8a1ad6e842bf68e3 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-gen-await-instn-iee-err-circular.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/instn-iee-err-circular.case +// - src/dynamic-import/catch/nested-async-generator-await.template +/*--- +description: IndirectExportEntries validation - circular imported bindings (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async-iteration] +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]]. + + + [...] + 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. + +---*/ + +async function * f() { + await import('./instn-iee-err-circular-1_FIXTURE.js'); +} + +f().next().catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-gen-await-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-async-gen-await-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000000000000000000000000000000000..7fa0854b460bfd08a6a3f8dc21815d9afc9d665a --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-gen-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-generator-await.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async-iteration] +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); +} + +f().next().catch(error => { + + assert.sameValue(error, 'custom error'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-eval-rqstd-abrupt-typeerror.js b/test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-eval-rqstd-abrupt-typeerror.js new file mode 100644 index 0000000000000000000000000000000000000000..c1626569c3123ea33ca6a82d890bfae59acd7eec --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-eval-rqstd-abrupt-typeerror.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-rqstd-abrupt-typeerror.case +// - src/dynamic-import/catch/nested-async-generator-return-await.template +/*--- +description: Abrupt completion during module evaluation precludes further evaluation (nested in async generator, returns awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async iteration] +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]]. + + + [...] + 6. For each String required that is an element of + module.[[RequestedModules]] do, + a. Let requiredModule be ? HostResolveImportedModule(module, required). + b. Perform ? requiredModule.ModuleEvaluation(). + +---*/ + +async function * f() { + return await import('./eval-rqstd-abrupt-err-type_FIXTURE.js'); +} + +f().next().catch(error => { + + assert.sameValue(error.name, 'TypeError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-eval-rqstd-abrupt-urierror.js b/test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-eval-rqstd-abrupt-urierror.js new file mode 100644 index 0000000000000000000000000000000000000000..4b83806eba45c353a3fd86bfad5c74cd158df2c4 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-eval-rqstd-abrupt-urierror.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-rqstd-abrupt-urierror.case +// - src/dynamic-import/catch/nested-async-generator-return-await.template +/*--- +description: Abrupt completion during module evaluation precludes further evaluation (nested in async generator, returns awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async iteration] +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]]. + + + [...] + 6. For each String required that is an element of + module.[[RequestedModules]] do, + a. Let requiredModule be ? HostResolveImportedModule(module, required). + b. Perform ? requiredModule.ModuleEvaluation(). + +---*/ + +async function * f() { + return await import('./eval-rqstd-abrupt-err-uri_FIXTURE.js'); +} + +f().next().catch(error => { + + assert.sameValue(error.name, 'URIError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-eval-script-code-target.js new file mode 100644 index 0000000000000000000000000000000000000000..24d5e4d64266f2bb252b49cbd3d908451c680b64 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-gen-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-generator-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 generator, returns awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async iteration] +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'); +} + +f().next().catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-file-does-not-exist.js b/test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-file-does-not-exist.js new file mode 100644 index 0000000000000000000000000000000000000000..c6ea7b85ce9731ce4185351642428b3bcfa994b3 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-file-does-not-exist.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/file-does-not-exist.case +// - src/dynamic-import/catch/nested-async-generator-return-await.template +/*--- +description: Non existent file can't resolve to a Script or Module Record (nested in async generator, returns awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async iteration] +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]]. + + + If a Module Record corresponding to the pair referencingModulereferencingScriptOrModule, + specifier does not exist or cannot be created, an exception must be thrown. + +---*/ + +async function * f() { + return await import('./THIS_FILE_DOES_NOT_EXIST.js'); +} + +f().next().catch(error => { + + assert.notSameValue(typeof error, 'undefined'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-instn-iee-err-ambiguous-import.js b/test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-instn-iee-err-ambiguous-import.js new file mode 100644 index 0000000000000000000000000000000000000000..8350c5f71e8c9342cf3af617e140121a72a9ecaa --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-instn-iee-err-ambiguous-import.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/instn-iee-err-ambiguous-import.case +// - src/dynamic-import/catch/nested-async-generator-return-await.template +/*--- +description: IndirectExportEntries validation - ambiguous imported bindings (nested in async generator, returns awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async iteration] +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]]. + + + [...] + 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". + +---*/ + +async function * f() { + return await import('./instn-iee-err-ambiguous-export_FIXTURE.js'); +} + +f().next().catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-instn-iee-err-circular.js b/test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-instn-iee-err-circular.js new file mode 100644 index 0000000000000000000000000000000000000000..1caa72210f2294827e3e52f9caaac5c6d0584898 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-instn-iee-err-circular.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/instn-iee-err-circular.case +// - src/dynamic-import/catch/nested-async-generator-return-await.template +/*--- +description: IndirectExportEntries validation - circular imported bindings (nested in async generator, returns awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async iteration] +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]]. + + + [...] + 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. + +---*/ + +async function * f() { + return await import('./instn-iee-err-circular-1_FIXTURE.js'); +} + +f().next().catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000000000000000000000000000000000..c77668c31a14d86bd8671957f6a7706d677075a0 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-gen-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-generator-return-await.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested in async generator, returns awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async iteration] +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); +} + +f().next().catch(error => { + + assert.sameValue(error, 'custom error'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-await-assignment-expr-not-optional.js b/test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-await-assignment-expr-not-optional.js new file mode 100644 index 0000000000000000000000000000000000000000..f181c9484a55b5c6564b30e181b0c7c4ab157885 --- /dev/null +++ b/test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-await-assignment-expr-not-optional.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/assignment-expr-not-optional.case +// - src/dynamic-import/syntax/invalid/nested-async-arrow-fn-await.template +/*--- +description: It's a SyntaxError if AssignmentExpression is omitted (nested in async arrow function, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +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]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) +---*/ + +throw "Test262: This statement should not be evaluated."; + +(async () => { + await import() +}); + +/* The params region intentionally empty */ diff --git a/test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-await-not-extensible-args.js b/test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-await-not-extensible-args.js new file mode 100644 index 0000000000000000000000000000000000000000..61edab92cd521bdd717d52df15b671f65601bef4 --- /dev/null +++ b/test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-await-not-extensible-args.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/not-extensible-args.case +// - src/dynamic-import/syntax/invalid/nested-async-arrow-fn-await.template +/*--- +description: ImportCall is not extensible - no arguments list (nested in async arrow function, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +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]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + Forbidden Extensions + + - ImportCall must not be extended. +---*/ + +throw "Test262: This statement should not be evaluated."; + +(async () => { + await import('', '') +}); diff --git a/test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-await-not-extensible-no-trailing-comma.js b/test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-await-not-extensible-no-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..6aedac9010c524e7eea9bcc32073627d289a7fc1 --- /dev/null +++ b/test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-await-not-extensible-no-trailing-comma.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/not-extensible-no-trailing-comma.case +// - src/dynamic-import/syntax/invalid/nested-async-arrow-fn-await.template +/*--- +description: ImportCall is not extensible - trailing comma (nested in async arrow function, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +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]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + Forbidden Extensions + + - ImportCall must not be extended. +---*/ + +throw "Test262: This statement should not be evaluated."; + +(async () => { + await import('',) +}); diff --git a/test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-assignment-expr-not-optional.js b/test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-assignment-expr-not-optional.js new file mode 100644 index 0000000000000000000000000000000000000000..8e2ad604ce8c3647848dd50921c9d7bcf9ec9a1b --- /dev/null +++ b/test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-assignment-expr-not-optional.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/assignment-expr-not-optional.case +// - src/dynamic-import/syntax/invalid/nested-async-arrow-fn-return-await.template +/*--- +description: It's a SyntaxError if AssignmentExpression is omitted (nested in async arrow function, returned) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +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]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) +---*/ + +throw "Test262: This statement should not be evaluated."; + +(async () => await import()) + +/* The params region intentionally empty */ diff --git a/test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-not-extensible-args.js b/test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-not-extensible-args.js new file mode 100644 index 0000000000000000000000000000000000000000..f3108aaabeb003eb412e6fb1970c15419769d905 --- /dev/null +++ b/test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-not-extensible-args.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/not-extensible-args.case +// - src/dynamic-import/syntax/invalid/nested-async-arrow-fn-return-await.template +/*--- +description: ImportCall is not extensible - no arguments list (nested in async arrow function, returned) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +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]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + Forbidden Extensions + + - ImportCall must not be extended. +---*/ + +throw "Test262: This statement should not be evaluated."; + +(async () => await import('', '')) diff --git a/test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-not-extensible-no-trailing-comma.js b/test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-not-extensible-no-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..9ee304e195a203f125dd66ce14ccbf04b93b1f0d --- /dev/null +++ b/test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-not-extensible-no-trailing-comma.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/not-extensible-no-trailing-comma.case +// - src/dynamic-import/syntax/invalid/nested-async-arrow-fn-return-await.template +/*--- +description: ImportCall is not extensible - trailing comma (nested in async arrow function, returned) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +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]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + Forbidden Extensions + + - ImportCall must not be extended. +---*/ + +throw "Test262: This statement should not be evaluated."; + +(async () => await import('',)) diff --git a/test/language/module-code/dynamic-import/syntax/invalid/nested-async-gen-await-assignment-expr-not-optional.js b/test/language/module-code/dynamic-import/syntax/invalid/nested-async-gen-await-assignment-expr-not-optional.js new file mode 100644 index 0000000000000000000000000000000000000000..6856f82526e2ed3f52dc7d55162f093647323a28 --- /dev/null +++ b/test/language/module-code/dynamic-import/syntax/invalid/nested-async-gen-await-assignment-expr-not-optional.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/assignment-expr-not-optional.case +// - src/dynamic-import/syntax/invalid/nested-async-generator-await.template +/*--- +description: It's a SyntaxError if AssignmentExpression is omitted (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +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]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) +---*/ + +throw "Test262: This statement should not be evaluated."; + +async function * f() { + await import() +} + +/* The params region intentionally empty */ diff --git a/test/language/module-code/dynamic-import/syntax/invalid/nested-async-gen-await-not-extensible-args.js b/test/language/module-code/dynamic-import/syntax/invalid/nested-async-gen-await-not-extensible-args.js new file mode 100644 index 0000000000000000000000000000000000000000..b1abb171d90976e413b02b9dab884f45c0c63ba5 --- /dev/null +++ b/test/language/module-code/dynamic-import/syntax/invalid/nested-async-gen-await-not-extensible-args.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/not-extensible-args.case +// - src/dynamic-import/syntax/invalid/nested-async-generator-await.template +/*--- +description: ImportCall is not extensible - no arguments list (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +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]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + Forbidden Extensions + + - ImportCall must not be extended. +---*/ + +throw "Test262: This statement should not be evaluated."; + +async function * f() { + await import('', '') +} diff --git a/test/language/module-code/dynamic-import/syntax/invalid/nested-async-gen-await-not-extensible-no-trailing-comma.js b/test/language/module-code/dynamic-import/syntax/invalid/nested-async-gen-await-not-extensible-no-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..494ca2ef6c6f047fa7d18489769a224f54ca02a8 --- /dev/null +++ b/test/language/module-code/dynamic-import/syntax/invalid/nested-async-gen-await-not-extensible-no-trailing-comma.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/not-extensible-no-trailing-comma.case +// - src/dynamic-import/syntax/invalid/nested-async-generator-await.template +/*--- +description: ImportCall is not extensible - trailing comma (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +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]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + Forbidden Extensions + + - ImportCall must not be extended. +---*/ + +throw "Test262: This statement should not be evaluated."; + +async function * f() { + await import('',) +} diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-await-empty-str-is-valid-assign-expr.js b/test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-await-empty-str-is-valid-assign-expr.js new file mode 100644 index 0000000000000000000000000000000000000000..72168bea35c68457b19e197680cf08f7c78558f3 --- /dev/null +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-await-empty-str-is-valid-assign-expr.js @@ -0,0 +1,27 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/empty-str-is-valid-assign-expr.case +// - src/dynamic-import/syntax/valid/nested-async-arrow-fn-await.template +/*--- +description: Calling import('') (nested in async arrow function) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +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]]. + +---*/ + +(async () => { + await import('') +}); diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-await-nested-imports.js b/test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-await-nested-imports.js new file mode 100644 index 0000000000000000000000000000000000000000..bb0821b3d70d5d168e54bddc33b39f09eebf6bb8 --- /dev/null +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-await-nested-imports.js @@ -0,0 +1,27 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/nested-imports.case +// - src/dynamic-import/syntax/valid/nested-async-arrow-fn-await.template +/*--- +description: ImportCall is a CallExpression can be nested in other import calls (nested in async arrow function) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +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]]. + +---*/ + +(async () => { + await import(import(import('./empty_FIXTURE.js'))) +}); diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-await-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-await-script-code-valid.js new file mode 100644 index 0000000000000000000000000000000000000000..6b41986a8b1360d3ebffa5acaa50d743edf2c4c7 --- /dev/null +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-await-script-code-valid.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/script-code-valid.case +// - src/dynamic-import/syntax/valid/nested-async-arrow-fn-await.template +/*--- +description: import() can be used in script code (nested in async arrow function) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +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 () => { + await import('./empty_FIXTURE.js') +}); diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-return-await-empty-str-is-valid-assign-expr.js b/test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-return-await-empty-str-is-valid-assign-expr.js new file mode 100644 index 0000000000000000000000000000000000000000..2ec457a5fa664f6bdaefddeb72c0d37ac1ecd701 --- /dev/null +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-return-await-empty-str-is-valid-assign-expr.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/empty-str-is-valid-assign-expr.case +// - src/dynamic-import/syntax/valid/nested-async-arrow-fn-return-await.template +/*--- +description: Calling import('') (nested in async arrow function, returned) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +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]]. + +---*/ + +(async () => await import('')); diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-return-await-nested-imports.js b/test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-return-await-nested-imports.js new file mode 100644 index 0000000000000000000000000000000000000000..c7d70122b54dcf71968668fd066e902fe60daed8 --- /dev/null +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-return-await-nested-imports.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/nested-imports.case +// - src/dynamic-import/syntax/valid/nested-async-arrow-fn-return-await.template +/*--- +description: ImportCall is a CallExpression can be nested in other import calls (nested in async arrow function, returned) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +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]]. + +---*/ + +(async () => await import(import(import('./empty_FIXTURE.js')))); diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-return-await-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-return-await-script-code-valid.js new file mode 100644 index 0000000000000000000000000000000000000000..615ec8e5d410582c0ca91c06ae3d9d7cd17f9e38 --- /dev/null +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-return-await-script-code-valid.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/script-code-valid.case +// - src/dynamic-import/syntax/valid/nested-async-arrow-fn-return-await.template +/*--- +description: import() can be used in script code (nested in async arrow function, returned) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +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 () => await import('./empty_FIXTURE.js')); diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-async-gen-await-empty-str-is-valid-assign-expr.js b/test/language/module-code/dynamic-import/syntax/valid/nested-async-gen-await-empty-str-is-valid-assign-expr.js new file mode 100644 index 0000000000000000000000000000000000000000..c027e08daa162370f3abcce7e0cc1b8f3a88dfbd --- /dev/null +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-async-gen-await-empty-str-is-valid-assign-expr.js @@ -0,0 +1,27 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/empty-str-is-valid-assign-expr.case +// - src/dynamic-import/syntax/valid/nested-async-generator-await.template +/*--- +description: Calling import('') (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async-iteration] +flags: [generated] +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]]. + +---*/ + +async function * f() { + await import('') +} diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-async-gen-await-nested-imports.js b/test/language/module-code/dynamic-import/syntax/valid/nested-async-gen-await-nested-imports.js new file mode 100644 index 0000000000000000000000000000000000000000..350294d2dccf02a56339939bd8494d96bb7a224b --- /dev/null +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-async-gen-await-nested-imports.js @@ -0,0 +1,27 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/nested-imports.case +// - src/dynamic-import/syntax/valid/nested-async-generator-await.template +/*--- +description: ImportCall is a CallExpression can be nested in other import calls (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async-iteration] +flags: [generated] +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]]. + +---*/ + +async function * f() { + await import(import(import('./empty_FIXTURE.js'))) +} diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-async-gen-await-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-async-gen-await-script-code-valid.js new file mode 100644 index 0000000000000000000000000000000000000000..6b5b5ed1048f521744c121544786ee0ff2229c54 --- /dev/null +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-async-gen-await-script-code-valid.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/script-code-valid.case +// - src/dynamic-import/syntax/valid/nested-async-generator-await.template +/*--- +description: import() can be used in script code (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async-iteration] +flags: [generated] +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('./empty_FIXTURE.js') +} diff --git a/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-await-eval-gtbndng-indirect-update-dflt.js b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-await-eval-gtbndng-indirect-update-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..96bb4e0f5eafb8b8d37c6b1ea7d3fbac9358a5f7 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-await-eval-gtbndng-indirect-update-dflt.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-gtbndng-indirect-update-dflt.case +// - src/dynamic-import/default/nested-async-arrow-fn-await.template +/*--- +description: Modifications to default binding that occur after dependency has been evaluated are reflected in local binding (nested in async arrow 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]]. + + + 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). + +---*/ + +const f = async () => { + await import('./eval-gtbndng-indirect-update-dflt_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default(), 1); + assert.sameValue(imported.default, 2); + + }); +} + +f().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-await-eval-gtbndng-indirect-update.js b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-await-eval-gtbndng-indirect-update.js new file mode 100644 index 0000000000000000000000000000000000000000..4d41cbbf72f9b1caaa99d660fa271ef30da88fc1 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-await-eval-gtbndng-indirect-update.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-gtbndng-indirect-update.case +// - src/dynamic-import/default/nested-async-arrow-fn-await.template +/*--- +description: Modifications to named bindings that occur after dependency has been evaluated are reflected in local binding (nested in async arrow function, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +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). + +---*/ + +const f = async () => { + await 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); + + + }); +} + +f().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-await-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-await-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000000000000000000000000000000000..96c55dfd4eb2b3cd44c130c83bf1bc8bf60399a9 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-arrow-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-arrow-fn-await.template +/*--- +description: import() from a ascript code can load a file with module code (nested in async arrow 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() {} + + +const f = async () => { + 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-arrow-function-await-is-call-expression-square-brackets.js b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-await-is-call-expression-square-brackets.js new file mode 100644 index 0000000000000000000000000000000000000000..100366cc0175980eb144f55d62ccfebd0df43e38 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-await-is-call-expression-square-brackets.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/is-call-expression-square-brackets.case +// - src/dynamic-import/default/nested-async-arrow-fn-await.template +/*--- +description: ImportCall is a CallExpression, it can be followed by square brackets (nested in async arrow 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]]. + +---*/ + +const f = async () => { + await import('./dynamic-import-module_FIXTURE.js')['then'](x => x).then(imported => { + + assert.sameValue(imported.x, 1); + + }); +} + +f().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-await-returns-thenable.js b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-await-returns-thenable.js new file mode 100644 index 0000000000000000000000000000000000000000..54532aee3514d874eba9a27d425f079bd9299c6e --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-await-returns-thenable.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/returns-thenable.case +// - src/dynamic-import/default/nested-async-arrow-fn-await.template +/*--- +description: Dynamic import() returns a thenable object. (nested in async arrow 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]]. + +---*/ + +const f = async () => { + await import('./dynamic-import-module_FIXTURE.js').then(imported => { + + assert.sameValue(imported.x, 1); + + }); +} + +f().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-await-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-await-specifier-tostring.js new file mode 100644 index 0000000000000000000000000000000000000000..e426ceb2f6d61fcf55b31dcd3829f96d787b5977 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-arrow-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-arrow-fn-await.template +/*--- +description: ToString value of specifier (nested in async arrow 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'; + } +}; + + +const f = async () => { + 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-arrow-function-return-await-eval-gtbndng-indirect-update-dflt.js b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-return-await-eval-gtbndng-indirect-update-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..48d00234e676e286dc26fb95504c69d807b41acd --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-return-await-eval-gtbndng-indirect-update-dflt.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-gtbndng-indirect-update-dflt.case +// - src/dynamic-import/default/nested-async-arrow-fn-return-await.template +/*--- +description: Modifications to default binding that occur after dependency has been evaluated are reflected in local binding (nested in async arrow function, returned) +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]]. + + + 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). + +---*/ + +const f = async () => await import('./eval-gtbndng-indirect-update-dflt_FIXTURE.js'); + +f().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-async-arrow-function-return-await-eval-gtbndng-indirect-update.js b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-return-await-eval-gtbndng-indirect-update.js new file mode 100644 index 0000000000000000000000000000000000000000..cbc86a73106367fda6a9105c2eb5d87c36434904 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-return-await-eval-gtbndng-indirect-update.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-gtbndng-indirect-update.case +// - src/dynamic-import/default/nested-async-arrow-fn-return-await.template +/*--- +description: Modifications to named bindings that occur after dependency has been evaluated are reflected in local binding (nested in async arrow function, returned) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +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). + +---*/ + +const f = async () => await import('./eval-gtbndng-indirect-update_FIXTURE.js'); + +f().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-async-arrow-function-return-await-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-return-await-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000000000000000000000000000000000..b34185b3f1e85bf160188ee3b2e87fdd5a35ed13 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-return-await-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-async-arrow-fn-return-await.template +/*--- +description: import() from a ascript code can load a file with module code (nested in async arrow function, returned) +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() {} + + +const f = async () => 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-arrow-function-return-await-is-call-expression-square-brackets.js b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-return-await-is-call-expression-square-brackets.js new file mode 100644 index 0000000000000000000000000000000000000000..df1de5a49b7ed017697a0746cabb8754e74ee50a --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-return-await-is-call-expression-square-brackets.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/is-call-expression-square-brackets.case +// - src/dynamic-import/default/nested-async-arrow-fn-return-await.template +/*--- +description: ImportCall is a CallExpression, it can be followed by square brackets (nested in async arrow function, returned) +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]]. + +---*/ + +const f = async () => await import('./dynamic-import-module_FIXTURE.js')['then'](x => x); + +f().then(imported => { + + assert.sameValue(imported.x, 1); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-return-await-returns-thenable.js b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-return-await-returns-thenable.js new file mode 100644 index 0000000000000000000000000000000000000000..0966039602c12edf2d6303e49ce72eae98942565 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-return-await-returns-thenable.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/returns-thenable.case +// - src/dynamic-import/default/nested-async-arrow-fn-return-await.template +/*--- +description: Dynamic import() returns a thenable object. (nested in async arrow function, returned) +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]]. + +---*/ + +const f = async () => await import('./dynamic-import-module_FIXTURE.js'); + +f().then(imported => { + + assert.sameValue(imported.x, 1); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-return-await-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-return-await-specifier-tostring.js new file mode 100644 index 0000000000000000000000000000000000000000..e952f52347cda061e5a22f577a84c7cecd9523ec --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-arrow-function-return-await-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-async-arrow-fn-return-await.template +/*--- +description: ToString value of specifier (nested in async arrow function, returned) +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'; + } +}; + + +const f = async () => 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-gen-await-eval-gtbndng-indirect-update-dflt.js b/test/language/module-code/dynamic-import/usage/nested-async-gen-await-eval-gtbndng-indirect-update-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..a68e7fd34bed67fbcce775b7450445ac0c4af587 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-gen-await-eval-gtbndng-indirect-update-dflt.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-gtbndng-indirect-update-dflt.case +// - src/dynamic-import/default/nested-async-generator-await.template +/*--- +description: Modifications to default binding that occur after dependency has been evaluated are reflected in local binding (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async-iteration] +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]]. + + + 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). + +---*/ + +let callCount = 0; + +async function * f() { + await import('./eval-gtbndng-indirect-update-dflt_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default(), 1); + assert.sameValue(imported.default, 2); + + callCount++; + }); +} + +f().next().then(() => { + assert.sameValue(callCount, 1); +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-gen-await-eval-gtbndng-indirect-update.js b/test/language/module-code/dynamic-import/usage/nested-async-gen-await-eval-gtbndng-indirect-update.js new file mode 100644 index 0000000000000000000000000000000000000000..3338d4147b30def378e048cfb3ea5e2f887db3ca --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-gen-await-eval-gtbndng-indirect-update.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-gtbndng-indirect-update.case +// - src/dynamic-import/default/nested-async-generator-await.template +/*--- +description: Modifications to named bindings that occur after dependency has been evaluated are reflected in local binding (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async-iteration] +flags: [generated, async] +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). + +---*/ + +let callCount = 0; + +async function * f() { + await 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); + + + callCount++; + }); +} + +f().next().then(() => { + assert.sameValue(callCount, 1); +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-gen-await-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-async-gen-await-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000000000000000000000000000000000..4c21eaf1b50842cde40d14f0dc5331c4a70599f5 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-gen-await-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,44 @@ +// 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-generator-await.template +/*--- +description: import() from a ascript code can load a file with module code (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async-iteration] +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 callCount = 0; + +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); + + callCount++; + }); +} + +f().next().then(() => { + assert.sameValue(callCount, 1); +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-gen-await-is-call-expression-square-brackets.js b/test/language/module-code/dynamic-import/usage/nested-async-gen-await-is-call-expression-square-brackets.js new file mode 100644 index 0000000000000000000000000000000000000000..b55f245f11540fa9fe91f2fe34569526aa33e83c --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-gen-await-is-call-expression-square-brackets.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/is-call-expression-square-brackets.case +// - src/dynamic-import/default/nested-async-generator-await.template +/*--- +description: ImportCall is a CallExpression, it can be followed by square brackets (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async-iteration] +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]]. + +---*/ + +let callCount = 0; + +async function * f() { + await import('./dynamic-import-module_FIXTURE.js')['then'](x => x).then(imported => { + + assert.sameValue(imported.x, 1); + + callCount++; + }); +} + +f().next().then(() => { + assert.sameValue(callCount, 1); +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-gen-await-returns-thenable.js b/test/language/module-code/dynamic-import/usage/nested-async-gen-await-returns-thenable.js new file mode 100644 index 0000000000000000000000000000000000000000..37cd989f72b802dcba12eb9e3ee4420f68b9d949 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-gen-await-returns-thenable.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/returns-thenable.case +// - src/dynamic-import/default/nested-async-generator-await.template +/*--- +description: Dynamic import() returns a thenable object. (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async-iteration] +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]]. + +---*/ + +let callCount = 0; + +async function * f() { + await import('./dynamic-import-module_FIXTURE.js').then(imported => { + + assert.sameValue(imported.x, 1); + + callCount++; + }); +} + +f().next().then(() => { + assert.sameValue(callCount, 1); +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-gen-await-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-async-gen-await-specifier-tostring.js new file mode 100644 index 0000000000000000000000000000000000000000..853bd7cb15d60578fd7fc66687dd8c2e3431aa30 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-gen-await-specifier-tostring.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-async-generator-await.template +/*--- +description: ToString value of specifier (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async-iteration] +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 callCount = 0; + +async function * f() { + await import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + callCount++; + }); +} + +f().next().then(() => { + assert.sameValue(callCount, 1); +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-gen-return-await-eval-gtbndng-indirect-update-dflt.js b/test/language/module-code/dynamic-import/usage/nested-async-gen-return-await-eval-gtbndng-indirect-update-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..1846e89e9e5d1858f918bc448609eb1a69d8b234 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-gen-return-await-eval-gtbndng-indirect-update-dflt.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-gtbndng-indirect-update-dflt.case +// - src/dynamic-import/default/nested-async-generator-return-await.template +/*--- +description: Modifications to default binding that occur after dependency has been evaluated are reflected in local binding (nested in async generator, returns awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async iteration] +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]]. + + + 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). + +---*/ + +async function * f() { + return await import('./eval-gtbndng-indirect-update-dflt_FIXTURE.js'); +} + +f().next().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-async-gen-return-await-eval-gtbndng-indirect-update.js b/test/language/module-code/dynamic-import/usage/nested-async-gen-return-await-eval-gtbndng-indirect-update.js new file mode 100644 index 0000000000000000000000000000000000000000..0069f2eac3e5b5ac576a504f293416ab04a01c2b --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-gen-return-await-eval-gtbndng-indirect-update.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-gtbndng-indirect-update.case +// - src/dynamic-import/default/nested-async-generator-return-await.template +/*--- +description: Modifications to named bindings that occur after dependency has been evaluated are reflected in local binding (nested in async generator, returns awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async iteration] +flags: [generated, async] +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). + +---*/ + +async function * f() { + return await import('./eval-gtbndng-indirect-update_FIXTURE.js'); +} + +f().next().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-async-gen-return-await-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-async-gen-return-await-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000000000000000000000000000000000..ee37f476568727b96ffb22a78e7681963499ab7b --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-gen-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-generator-return-await.template +/*--- +description: import() from a ascript code can load a file with module code (nested in async generator, returns awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async iteration] +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().next().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-gen-return-await-is-call-expression-square-brackets.js b/test/language/module-code/dynamic-import/usage/nested-async-gen-return-await-is-call-expression-square-brackets.js new file mode 100644 index 0000000000000000000000000000000000000000..2c70f456e712d104b9ad79419864cede48d8043b --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-gen-return-await-is-call-expression-square-brackets.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/is-call-expression-square-brackets.case +// - src/dynamic-import/default/nested-async-generator-return-await.template +/*--- +description: ImportCall is a CallExpression, it can be followed by square brackets (nested in async generator, returns awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async iteration] +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]]. + +---*/ + +async function * f() { + return await import('./dynamic-import-module_FIXTURE.js')['then'](x => x); +} + +f().next().then(imported => { + + assert.sameValue(imported.x, 1); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-gen-return-await-returns-thenable.js b/test/language/module-code/dynamic-import/usage/nested-async-gen-return-await-returns-thenable.js new file mode 100644 index 0000000000000000000000000000000000000000..f644276e369350216479e8a1879fadb6573ff3ea --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-gen-return-await-returns-thenable.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/returns-thenable.case +// - src/dynamic-import/default/nested-async-generator-return-await.template +/*--- +description: Dynamic import() returns a thenable object. (nested in async generator, returns awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async iteration] +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]]. + +---*/ + +async function * f() { + return await import('./dynamic-import-module_FIXTURE.js'); +} + +f().next().then(imported => { + + assert.sameValue(imported.x, 1); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-gen-return-await-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-async-gen-return-await-specifier-tostring.js new file mode 100644 index 0000000000000000000000000000000000000000..3ec34ea390b481200d9a6d800c6e460e0f2a0896 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-gen-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-generator-return-await.template +/*--- +description: ToString value of specifier (nested in async generator, returns awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async iteration] +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().next().then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + +}).then($DONE, $DONE).catch($DONE);