From aefadabda71be131b157a8a89d683408979e7e0a Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Wed, 17 Oct 2018 12:15:20 -0400 Subject: [PATCH] Generate tests --- ...ction-await-eval-rqstd-abrupt-typeerror.js | 40 ++++++++++++ ...nction-await-eval-rqstd-abrupt-urierror.js | 40 ++++++++++++ ...-function-await-eval-script-code-target.js | 42 +++++++++++++ ...rrow-function-await-file-does-not-exist.js | 37 +++++++++++ ...on-await-instn-iee-err-ambiguous-import.js | 61 ++++++++++++++++++ ...w-function-await-instn-iee-err-circular.js | 50 +++++++++++++++ ...await-specifier-tostring-abrupt-rejects.js | 55 ++++++++++++++++ ...eturn-await-eval-rqstd-abrupt-typeerror.js | 38 ++++++++++++ ...return-await-eval-rqstd-abrupt-urierror.js | 38 ++++++++++++ ...on-return-await-eval-script-code-target.js | 40 ++++++++++++ ...nction-return-await-file-does-not-exist.js | 35 +++++++++++ ...rn-await-instn-iee-err-ambiguous-import.js | 59 ++++++++++++++++++ ...ion-return-await-instn-iee-err-circular.js | 48 ++++++++++++++ ...await-specifier-tostring-abrupt-rejects.js | 53 ++++++++++++++++ ...c-gen-await-eval-rqstd-abrupt-typeerror.js | 40 ++++++++++++ ...nc-gen-await-eval-rqstd-abrupt-urierror.js | 40 ++++++++++++ ...async-gen-await-eval-script-code-target.js | 42 +++++++++++++ ...ted-async-gen-await-file-does-not-exist.js | 37 +++++++++++ ...en-await-instn-iee-err-ambiguous-import.js | 61 ++++++++++++++++++ ...-async-gen-await-instn-iee-err-circular.js | 50 +++++++++++++++ ...await-specifier-tostring-abrupt-rejects.js | 55 ++++++++++++++++ ...eturn-await-eval-rqstd-abrupt-typeerror.js | 40 ++++++++++++ ...return-await-eval-rqstd-abrupt-urierror.js | 40 ++++++++++++ ...en-return-await-eval-script-code-target.js | 42 +++++++++++++ ...nc-gen-return-await-file-does-not-exist.js | 37 +++++++++++ ...rn-await-instn-iee-err-ambiguous-import.js | 61 ++++++++++++++++++ ...gen-return-await-instn-iee-err-circular.js | 50 +++++++++++++++ ...await-specifier-tostring-abrupt-rejects.js | 55 ++++++++++++++++ ...tion-await-assignment-expr-not-optional.js | 37 +++++++++++ ...rrow-function-await-not-extensible-args.js | 39 ++++++++++++ ...-await-not-extensible-no-trailing-comma.js | 39 ++++++++++++ ...turn-await-assignment-expr-not-optional.js | 35 +++++++++++ ...nction-return-await-not-extensible-args.js | 37 +++++++++++ ...-await-not-extensible-no-trailing-comma.js | 37 +++++++++++ ...-gen-await-assignment-expr-not-optional.js | 37 +++++++++++ ...ted-async-gen-await-not-extensible-args.js | 39 ++++++++++++ ...-await-not-extensible-no-trailing-comma.js | 39 ++++++++++++ ...on-await-empty-str-is-valid-assign-expr.js | 27 ++++++++ ...ync-arrow-function-await-nested-imports.js | 27 ++++++++ ...-arrow-function-await-script-code-valid.js | 31 ++++++++++ ...rn-await-empty-str-is-valid-assign-expr.js | 25 ++++++++ ...ow-function-return-await-nested-imports.js | 25 ++++++++ ...function-return-await-script-code-valid.js | 29 +++++++++ ...en-await-empty-str-is-valid-assign-expr.js | 27 ++++++++ .../nested-async-gen-await-nested-imports.js | 27 ++++++++ ...ested-async-gen-await-script-code-valid.js | 31 ++++++++++ ...await-eval-gtbndng-indirect-update-dflt.js | 46 ++++++++++++++ ...tion-await-eval-gtbndng-indirect-update.js | 54 ++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 39 ++++++++++++ ...wait-is-call-expression-square-brackets.js | 33 ++++++++++ ...c-arrow-function-await-returns-thenable.js | 33 ++++++++++ ...arrow-function-await-specifier-tostring.js | 57 +++++++++++++++++ ...await-eval-gtbndng-indirect-update-dflt.js | 44 +++++++++++++ ...turn-await-eval-gtbndng-indirect-update.js | 52 ++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 37 +++++++++++ ...wait-is-call-expression-square-brackets.js | 31 ++++++++++ ...-function-return-await-returns-thenable.js | 31 ++++++++++ ...unction-return-await-specifier-tostring.js | 55 ++++++++++++++++ ...await-eval-gtbndng-indirect-update-dflt.js | 51 +++++++++++++++ ...-gen-await-eval-gtbndng-indirect-update.js | 59 ++++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 44 +++++++++++++ ...wait-is-call-expression-square-brackets.js | 38 ++++++++++++ ...nested-async-gen-await-returns-thenable.js | 38 ++++++++++++ ...sted-async-gen-await-specifier-tostring.js | 62 +++++++++++++++++++ ...await-eval-gtbndng-indirect-update-dflt.js | 46 ++++++++++++++ ...turn-await-eval-gtbndng-indirect-update.js | 54 ++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 39 ++++++++++++ ...wait-is-call-expression-square-brackets.js | 33 ++++++++++ ...async-gen-return-await-returns-thenable.js | 33 ++++++++++ ...ync-gen-return-await-specifier-tostring.js | 57 +++++++++++++++++ 70 files changed, 2940 insertions(+) create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-eval-rqstd-abrupt-typeerror.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-eval-rqstd-abrupt-urierror.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-file-does-not-exist.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-instn-iee-err-ambiguous-import.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-instn-iee-err-circular.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-arrow-function-await-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-eval-rqstd-abrupt-typeerror.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-eval-rqstd-abrupt-urierror.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-file-does-not-exist.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-instn-iee-err-ambiguous-import.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-instn-iee-err-circular.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-arrow-function-return-await-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-gen-await-eval-rqstd-abrupt-typeerror.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-gen-await-eval-rqstd-abrupt-urierror.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-gen-await-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-gen-await-file-does-not-exist.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-gen-await-instn-iee-err-ambiguous-import.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-gen-await-instn-iee-err-circular.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-gen-await-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-eval-rqstd-abrupt-typeerror.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-eval-rqstd-abrupt-urierror.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-file-does-not-exist.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-instn-iee-err-ambiguous-import.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-instn-iee-err-circular.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-gen-return-await-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-await-assignment-expr-not-optional.js create mode 100644 test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-await-not-extensible-args.js create mode 100644 test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-await-not-extensible-no-trailing-comma.js create mode 100644 test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-assignment-expr-not-optional.js create mode 100644 test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-not-extensible-args.js create mode 100644 test/language/module-code/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-not-extensible-no-trailing-comma.js create mode 100644 test/language/module-code/dynamic-import/syntax/invalid/nested-async-gen-await-assignment-expr-not-optional.js create mode 100644 test/language/module-code/dynamic-import/syntax/invalid/nested-async-gen-await-not-extensible-args.js create mode 100644 test/language/module-code/dynamic-import/syntax/invalid/nested-async-gen-await-not-extensible-no-trailing-comma.js create mode 100644 test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-await-empty-str-is-valid-assign-expr.js create mode 100644 test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-await-nested-imports.js create mode 100644 test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-await-script-code-valid.js create mode 100644 test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-return-await-empty-str-is-valid-assign-expr.js create mode 100644 test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-return-await-nested-imports.js create mode 100644 test/language/module-code/dynamic-import/syntax/valid/nested-async-arrow-function-return-await-script-code-valid.js create mode 100644 test/language/module-code/dynamic-import/syntax/valid/nested-async-gen-await-empty-str-is-valid-assign-expr.js create mode 100644 test/language/module-code/dynamic-import/syntax/valid/nested-async-gen-await-nested-imports.js create mode 100644 test/language/module-code/dynamic-import/syntax/valid/nested-async-gen-await-script-code-valid.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-arrow-function-await-eval-gtbndng-indirect-update-dflt.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-arrow-function-await-eval-gtbndng-indirect-update.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-arrow-function-await-eval-script-code-host-resolves-module-code.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-arrow-function-await-is-call-expression-square-brackets.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-arrow-function-await-returns-thenable.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-arrow-function-await-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-arrow-function-return-await-eval-gtbndng-indirect-update-dflt.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-arrow-function-return-await-eval-gtbndng-indirect-update.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-arrow-function-return-await-eval-script-code-host-resolves-module-code.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-arrow-function-return-await-is-call-expression-square-brackets.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-arrow-function-return-await-returns-thenable.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-arrow-function-return-await-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-gen-await-eval-gtbndng-indirect-update-dflt.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-gen-await-eval-gtbndng-indirect-update.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-gen-await-eval-script-code-host-resolves-module-code.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-gen-await-is-call-expression-square-brackets.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-gen-await-returns-thenable.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-gen-await-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-gen-return-await-eval-gtbndng-indirect-update-dflt.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-gen-return-await-eval-gtbndng-indirect-update.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-gen-return-await-eval-script-code-host-resolves-module-code.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-gen-return-await-is-call-expression-square-brackets.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-gen-return-await-returns-thenable.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-gen-return-await-specifier-tostring.js 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 0000000000..03f0780f47 --- /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 0000000000..398935712c --- /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 0000000000..ca460e1b97 --- /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 0000000000..7f373e27bc --- /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 0000000000..ef8f81e161 --- /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 0000000000..b5c8b1dd11 --- /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 0000000000..416932c3f3 --- /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 0000000000..9578a86027 --- /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 0000000000..c336582f10 --- /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 0000000000..4b9c53abdc --- /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 0000000000..a6128b230b --- /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 0000000000..f7ae233728 --- /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 0000000000..634db6b198 --- /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 0000000000..35c45d55f0 --- /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 0000000000..eca64bb0fb --- /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 0000000000..5955e4f28c --- /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 0000000000..2ac7d212c3 --- /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 0000000000..07fb2ca3cb --- /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 0000000000..75e04b0c28 --- /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 0000000000..a47d46a304 --- /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 0000000000..7fa0854b46 --- /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 0000000000..c1626569c3 --- /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 0000000000..4b83806eba --- /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 0000000000..24d5e4d642 --- /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 0000000000..c6ea7b85ce --- /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 0000000000..8350c5f71e --- /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 0000000000..1caa72210f --- /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 0000000000..c77668c31a --- /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 0000000000..f181c9484a --- /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 0000000000..61edab92cd --- /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 0000000000..6aedac9010 --- /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 0000000000..8e2ad604ce --- /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 0000000000..f3108aaabe --- /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 0000000000..9ee304e195 --- /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 0000000000..6856f82526 --- /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 0000000000..b1abb171d9 --- /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 0000000000..494ca2ef6c --- /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 0000000000..72168bea35 --- /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 0000000000..bb0821b3d7 --- /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 0000000000..6b41986a8b --- /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 0000000000..2ec457a5fa --- /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 0000000000..c7d70122b5 --- /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 0000000000..615ec8e5d4 --- /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 0000000000..c027e08daa --- /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 0000000000..350294d2dc --- /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 0000000000..6b5b5ed104 --- /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 0000000000..96bb4e0f5e --- /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 0000000000..4d41cbbf72 --- /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 0000000000..96c55dfd4e --- /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 0000000000..100366cc01 --- /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 0000000000..54532aee35 --- /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 0000000000..e426ceb2f6 --- /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 0000000000..48d00234e6 --- /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 0000000000..cbc86a7310 --- /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 0000000000..b34185b3f1 --- /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 0000000000..df1de5a49b --- /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 0000000000..0966039602 --- /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 0000000000..e952f52347 --- /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 0000000000..a68e7fd34b --- /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 0000000000..3338d4147b --- /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 0000000000..4c21eaf1b5 --- /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 0000000000..b55f245f11 --- /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 0000000000..37cd989f72 --- /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 0000000000..853bd7cb15 --- /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 0000000000..1846e89e9e --- /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 0000000000..0069f2eac3 --- /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 0000000000..ee37f47656 --- /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 0000000000..2c70f456e7 --- /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 0000000000..f644276e36 --- /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 0000000000..3ec34ea390 --- /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);