From 070198fbadfe84843b911d304497af8a8c2db46c Mon Sep 17 00:00:00 2001 From: Leo Balter <leonardo.balter@gmail.com> Date: Tue, 9 Oct 2018 14:17:35 -0400 Subject: [PATCH] Generate tests --- ...ow-import-catch-eval-script-code-target.js | 42 ++++++++++++++ ...catch-specifier-tostring-abrupt-rejects.js | 55 ++++++++++++++++++ ...-function-await-eval-script-code-target.js | 42 ++++++++++++++ ...await-specifier-tostring-abrupt-rejects.js | 55 ++++++++++++++++++ ...-async-function-eval-script-code-target.js | 43 ++++++++++++++ ...on-return-await-eval-script-code-target.js | 42 ++++++++++++++ ...await-specifier-tostring-abrupt-rejects.js | 55 ++++++++++++++++++ ...ction-specifier-tostring-abrupt-rejects.js | 56 ++++++++++++++++++ ...ck-import-catch-eval-script-code-target.js | 40 +++++++++++++ ...catch-specifier-tostring-abrupt-rejects.js | 53 +++++++++++++++++ ...d-block-labeled-eval-script-code-target.js | 40 +++++++++++++ ...beled-specifier-tostring-abrupt-rejects.js | 53 +++++++++++++++++ ...nested-do-while-eval-script-code-target.js | 40 +++++++++++++ ...while-specifier-tostring-abrupt-rejects.js | 53 +++++++++++++++++ ...se-import-catch-eval-script-code-target.js | 42 ++++++++++++++ ...catch-specifier-tostring-abrupt-rejects.js | 55 ++++++++++++++++++ ...on-import-catch-eval-script-code-target.js | 41 +++++++++++++ ...catch-specifier-tostring-abrupt-rejects.js | 54 +++++++++++++++++ ...if-import-catch-eval-script-code-target.js | 40 +++++++++++++ ...catch-specifier-tostring-abrupt-rejects.js | 53 +++++++++++++++++ ...le-import-catch-eval-script-code-target.js | 42 ++++++++++++++ ...catch-specifier-tostring-abrupt-rejects.js | 55 ++++++++++++++++++ ...el-import-catch-eval-script-code-target.js | 38 ++++++++++++ ...catch-specifier-tostring-abrupt-rejects.js | 51 ++++++++++++++++ ...assignment-expression-script-code-valid.js | 2 +- .../valid/nested-arrow-script-code-valid.js | 2 +- ...-async-function-await-script-code-valid.js | 2 +- ...function-return-await-script-code-valid.js | 2 +- ...nested-async-function-script-code-valid.js | 2 +- .../nested-block-labeled-script-code-valid.js | 2 +- .../valid/nested-block-script-code-valid.js | 2 +- .../nested-do-while-script-code-valid.js | 2 +- ...nested-else-braceless-script-code-valid.js | 2 +- .../valid/nested-else-script-code-valid.js | 2 +- ...ested-function-return-script-code-valid.js | 2 +- .../nested-function-script-code-valid.js | 2 +- .../nested-if-braceless-script-code-valid.js | 2 +- .../valid/nested-if-script-code-valid.js | 2 +- .../valid/nested-while-script-code-valid.js | 2 +- .../valid/nested-with-script-code-valid.js | 2 +- .../valid/top-level-script-code-valid.js | 2 +- ...l-script-code-host-resolves-module-code.js | 38 ++++++++++++ ...assignment-expression-returns-thenable.js} | 4 +- ...ssignment-expression-specifier-tostring.js | 56 ++++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 40 +++++++++++++ ...ted-arrow-import-then-returns-thenable.js} | 4 +- ...ed-arrow-import-then-specifier-tostring.js | 58 +++++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 39 +++++++++++++ ...-async-function-await-returns-thenable.js} | 4 +- ...async-function-await-specifier-tostring.js | 57 ++++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 39 +++++++++++++ ...l-script-code-host-resolves-module-code.js | 39 +++++++++++++ ...function-return-await-returns-thenable.js} | 4 +- ...unction-return-await-specifier-tostring.js | 57 ++++++++++++++++++ ...nested-async-function-returns-thenable.js} | 4 +- ...ested-async-function-specifier-tostring.js | 57 ++++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 37 ++++++++++++ ...ted-block-import-then-returns-thenable.js} | 4 +- ...ed-block-import-then-specifier-tostring.js | 55 ++++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 37 ++++++++++++ ...js => nested-do-while-returns-thenable.js} | 4 +- .../nested-do-while-specifier-tostring.js | 55 ++++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 39 +++++++++++++ ...sted-else-import-then-returns-thenable.js} | 4 +- ...ted-else-import-then-specifier-tostring.js | 57 ++++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 38 ++++++++++++ ...-function-import-then-returns-thenable.js} | 4 +- ...function-import-then-specifier-tostring.js | 56 ++++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 35 +++++++++++ ...> nested-if-braceless-returns-thenable.js} | 4 +- .../nested-if-braceless-specifier-tostring.js | 53 +++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 37 ++++++++++++ ...nested-if-import-then-returns-thenable.js} | 4 +- ...ested-if-import-then-specifier-tostring.js | 55 ++++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 39 +++++++++++++ ...ted-while-import-then-returns-thenable.js} | 4 +- ...ed-while-import-then-specifier-tostring.js | 57 ++++++++++++++++++ ...-then-eval-gtbndng-indirect-update-dflt.js | 44 -------------- ...mport-then-eval-gtbndng-indirect-update.js | 52 ----------------- ...then-is-call-expression-square-brackets.js | 31 ---------- ...nested-with-import-then-returns-promise.js | 31 ---------- ...l-script-code-host-resolves-module-code.js | 37 ++++++++++++ ...-nested-block-labeled-returns-thenable.js} | 4 +- ...nested-block-labeled-specifier-tostring.js | 55 ++++++++++++++++++ ...l-script-code-host-resolves-module-code.js | 35 +++++++++++ ...top-level-import-then-returns-thenable.js} | 4 +- ...op-level-import-then-specifier-tostring.js | 53 +++++++++++++++++ 87 files changed, 2495 insertions(+), 203 deletions(-) create mode 100644 test/language/module-code/dynamic-import/catch/nested-arrow-import-catch-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-arrow-import-catch-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-function-await-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-function-await-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-function-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-function-return-await-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-function-return-await-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-async-function-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-block-import-catch-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-block-import-catch-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-block-labeled-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-block-labeled-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-do-while-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-do-while-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-else-import-catch-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-else-import-catch-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-function-import-catch-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-function-import-catch-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-if-import-catch-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-if-import-catch-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-while-import-catch-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/nested-while-import-catch-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/catch/top-level-import-catch-eval-script-code-target.js create mode 100644 test/language/module-code/dynamic-import/catch/top-level-import-catch-specifier-tostring-abrupt-rejects.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-arrow-assignment-expression-returns-promise.js => nested-arrow-assignment-expression-returns-thenable.js} (90%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-arrow-import-then-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-arrow-import-then-returns-promise.js => nested-arrow-import-then-returns-thenable.js} (90%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-arrow-import-then-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-function-await-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-async-function-await-returns-promise.js => nested-async-function-await-returns-thenable.js} (88%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-function-await-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-function-eval-script-code-host-resolves-module-code.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-function-return-await-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-async-function-return-await-returns-promise.js => nested-async-function-return-await-returns-thenable.js} (88%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-function-return-await-specifier-tostring.js rename test/language/module-code/dynamic-import/usage/{nested-async-function-returns-promise.js => nested-async-function-returns-thenable.js} (89%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-async-function-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-block-import-then-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-block-import-then-returns-promise.js => nested-block-import-then-returns-thenable.js} (90%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-block-import-then-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-do-while-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-do-while-returns-promise.js => nested-do-while-returns-thenable.js} (89%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-do-while-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-else-import-then-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-else-import-then-returns-promise.js => nested-else-import-then-returns-thenable.js} (90%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-else-import-then-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-function-import-then-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-function-import-then-returns-promise.js => nested-function-import-then-returns-thenable.js} (90%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-function-import-then-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-if-braceless-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-if-braceless-returns-promise.js => nested-if-braceless-returns-thenable.js} (89%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-if-braceless-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-if-import-then-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-if-import-then-returns-promise.js => nested-if-import-then-returns-thenable.js} (90%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-if-import-then-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/nested-while-import-then-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{nested-while-import-then-returns-promise.js => nested-while-import-then-returns-thenable.js} (90%) create mode 100644 test/language/module-code/dynamic-import/usage/nested-while-import-then-specifier-tostring.js delete mode 100644 test/language/module-code/dynamic-import/usage/nested-with-import-then-eval-gtbndng-indirect-update-dflt.js delete mode 100644 test/language/module-code/dynamic-import/usage/nested-with-import-then-eval-gtbndng-indirect-update.js delete mode 100644 test/language/module-code/dynamic-import/usage/nested-with-import-then-is-call-expression-square-brackets.js delete mode 100644 test/language/module-code/dynamic-import/usage/nested-with-import-then-returns-promise.js create mode 100644 test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{syntax-nested-block-labeled-returns-promise.js => syntax-nested-block-labeled-returns-thenable.js} (89%) create mode 100644 test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-specifier-tostring.js create mode 100644 test/language/module-code/dynamic-import/usage/top-level-import-then-eval-script-code-host-resolves-module-code.js rename test/language/module-code/dynamic-import/usage/{top-level-import-then-returns-promise.js => top-level-import-then-returns-thenable.js} (90%) create mode 100644 test/language/module-code/dynamic-import/usage/top-level-import-then-specifier-tostring.js diff --git a/test/language/module-code/dynamic-import/catch/nested-arrow-import-catch-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-arrow-import-catch-eval-script-code-target.js new file mode 100644 index 0000000000..fa6011eea3 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-arrow-import-catch-eval-script-code-target.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-arrow.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested arrow) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +let f = () => { + import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +}; + +f(); diff --git a/test/language/module-code/dynamic-import/catch/nested-arrow-import-catch-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-arrow-import-catch-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000..c5ed7e5264 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-arrow-import-catch-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-arrow.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested arrow) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +let f = () => { + import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +}; + +f(); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-function-await-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-async-function-await-eval-script-code-target.js new file mode 100644 index 0000000000..94703c2121 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-function-await-eval-script-code-target.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-async-function-await.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested in async function, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +async function f() { + await import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +} + +f(); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-function-await-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-async-function-await-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000..64e013be11 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-function-await-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-async-function-await.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested in async function, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +async function f() { + await import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +} + +f(); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-function-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-async-function-eval-script-code-target.js new file mode 100644 index 0000000000..c2b5b19daa --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-function-eval-script-code-target.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-async-function.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested in async function) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +async function f() { + import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +} + +f(); + diff --git a/test/language/module-code/dynamic-import/catch/nested-async-function-return-await-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-async-function-return-await-eval-script-code-target.js new file mode 100644 index 0000000000..f63156e9e0 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-function-return-await-eval-script-code-target.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-async-function-return-await.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested in async function, returns awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +async function f() { + return await import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +} + +f(); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-function-return-await-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-async-function-return-await-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000..f3ec1bfb54 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-function-return-await-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-async-function-return-await.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested in async function, returns awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +async function f() { + return await import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +} + +f(); diff --git a/test/language/module-code/dynamic-import/catch/nested-async-function-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-async-function-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000..70e3352eb0 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-async-function-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-async-function.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested in async function) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +async function f() { + import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +} + +f(); + diff --git a/test/language/module-code/dynamic-import/catch/nested-block-import-catch-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-block-import-catch-eval-script-code-target.js new file mode 100644 index 0000000000..aa11268fa6 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-block-import-catch-eval-script-code-target.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-block.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested block) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +{ + import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +}; diff --git a/test/language/module-code/dynamic-import/catch/nested-block-import-catch-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-block-import-catch-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000..4a6398c768 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-block-import-catch-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-block.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested block) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +{ + import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +}; diff --git a/test/language/module-code/dynamic-import/catch/nested-block-labeled-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-block-labeled-eval-script-code-target.js new file mode 100644 index 0000000000..7beb7101b1 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-block-labeled-eval-script-code-target.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-block-labeled.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested block syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +label: { + import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +}; diff --git a/test/language/module-code/dynamic-import/catch/nested-block-labeled-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-block-labeled-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000..b6723a7059 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-block-labeled-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-block-labeled.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested block syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +label: { + import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +}; diff --git a/test/language/module-code/dynamic-import/catch/nested-do-while-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-do-while-eval-script-code-target.js new file mode 100644 index 0000000000..4fd908472d --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-do-while-eval-script-code-target.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-do-while.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested do while syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +do { + import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +} while (false); diff --git a/test/language/module-code/dynamic-import/catch/nested-do-while-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-do-while-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000..7525280a08 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-do-while-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-do-while.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested do while syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +do { + import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +} while (false); diff --git a/test/language/module-code/dynamic-import/catch/nested-else-import-catch-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-else-import-catch-eval-script-code-target.js new file mode 100644 index 0000000000..001ff761a6 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-else-import-catch-eval-script-code-target.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-else.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested else) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +if (false) { + +} else { + import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +} diff --git a/test/language/module-code/dynamic-import/catch/nested-else-import-catch-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-else-import-catch-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000..6d8e0223ba --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-else-import-catch-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-else.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested else) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +if (false) { + +} else { + import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +} diff --git a/test/language/module-code/dynamic-import/catch/nested-function-import-catch-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-function-import-catch-eval-script-code-target.js new file mode 100644 index 0000000000..f1f8d81cb3 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-function-import-catch-eval-script-code-target.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-function.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested function) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +function f() { + import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +} +f(); diff --git a/test/language/module-code/dynamic-import/catch/nested-function-import-catch-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-function-import-catch-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000..1917a05566 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-function-import-catch-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-function.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested function) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +function f() { + import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +} +f(); diff --git a/test/language/module-code/dynamic-import/catch/nested-if-import-catch-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-if-import-catch-eval-script-code-target.js new file mode 100644 index 0000000000..86a7e0250f --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-if-import-catch-eval-script-code-target.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-if.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested if) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +if (true) { + import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +} diff --git a/test/language/module-code/dynamic-import/catch/nested-if-import-catch-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-if-import-catch-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000..eca30e05e0 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-if-import-catch-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-if.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested if) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +if (true) { + import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +} diff --git a/test/language/module-code/dynamic-import/catch/nested-while-import-catch-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/nested-while-import-catch-eval-script-code-target.js new file mode 100644 index 0000000000..8676fd92c4 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-while-import-catch-eval-script-code-target.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/nested-while.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (nested while) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +let x = 0; +while (!x) { + x++; + import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + + }).then($DONE, $DONE); +}; diff --git a/test/language/module-code/dynamic-import/catch/nested-while-import-catch-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/nested-while-import-catch-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000..ddf0987e06 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/nested-while-import-catch-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/nested-while.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (nested while) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +let x = 0; +while (!x) { + x++; + import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + + }).then($DONE, $DONE); +}; diff --git a/test/language/module-code/dynamic-import/catch/top-level-import-catch-eval-script-code-target.js b/test/language/module-code/dynamic-import/catch/top-level-import-catch-eval-script-code-target.js new file mode 100644 index 0000000000..daae4c13fe --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/top-level-import-catch-eval-script-code-target.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-target.case +// - src/dynamic-import/catch/top-level.template +/*--- +description: import() from a module code can load a file with script code, but the target is resolved into a Module Record (top level) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, module, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Modules + + Static Semantics: Early Errors + + ModuleBody : ModuleItemList + - It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList containsany duplicate entries. + - It is a Syntax Error if any element of the LexicallyDeclaredNames of ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList. + +---*/ + +import('./script-code_FIXTURE.js').catch(error => { + + assert.sameValue(error.name, 'SyntaxError'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/catch/top-level-import-catch-specifier-tostring-abrupt-rejects.js b/test/language/module-code/dynamic-import/catch/top-level-import-catch-specifier-tostring-abrupt-rejects.js new file mode 100644 index 0000000000..02ecae37f5 --- /dev/null +++ b/test/language/module-code/dynamic-import/catch/top-level-import-catch-specifier-tostring-abrupt-rejects.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring-abrupt-rejects.case +// - src/dynamic-import/catch/top-level.template +/*--- +description: Abrupt from ToString(specifier) rejects the promise (top level) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + throw 'custom error'; + } +}; + + +import(obj).catch(error => { + + assert.sameValue(error, 'custom error'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-arrow-assignment-expression-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-arrow-assignment-expression-script-code-valid.js index c5654cd220..c2f9ad358f 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-arrow-assignment-expression-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-arrow-assignment-expression-script-code-valid.js @@ -26,4 +26,4 @@ info: | var smoosh; function smoosh() {} -let f = () => import('./script-code-valid.js'); +let f = () => import('./empty_FIXTURE.js'); diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-arrow-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-arrow-script-code-valid.js index 590fff106f..d0b96c3678 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-arrow-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-arrow-script-code-valid.js @@ -27,5 +27,5 @@ var smoosh; function smoosh() {} let f = () => { - import('./script-code-valid.js'); + import('./empty_FIXTURE.js'); }; diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-await-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-await-script-code-valid.js index 90849fabfe..111ba41252 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-await-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-await-script-code-valid.js @@ -27,5 +27,5 @@ var smoosh; function smoosh() {} async function f() { - await import('./script-code-valid.js'); + await import('./empty_FIXTURE.js'); } diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-return-await-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-return-await-script-code-valid.js index f383065913..94225d6120 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-return-await-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-return-await-script-code-valid.js @@ -27,6 +27,6 @@ var smoosh; function smoosh() {} async function f() { - return await import('./script-code-valid.js'); + return await import('./empty_FIXTURE.js'); } diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-script-code-valid.js index e00d0a7ffd..9b28f3564e 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-async-function-script-code-valid.js @@ -27,6 +27,6 @@ var smoosh; function smoosh() {} async function f() { - import('./script-code-valid.js'); + import('./empty_FIXTURE.js'); } diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-block-labeled-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-block-labeled-script-code-valid.js index 0d36b64b70..cce923e15e 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-block-labeled-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-block-labeled-script-code-valid.js @@ -27,5 +27,5 @@ var smoosh; function smoosh() {} label: { - import('./script-code-valid.js'); + import('./empty_FIXTURE.js'); }; diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-block-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-block-script-code-valid.js index f66e994bd0..5cad7f4698 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-block-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-block-script-code-valid.js @@ -27,5 +27,5 @@ var smoosh; function smoosh() {} { - import('./script-code-valid.js'); + import('./empty_FIXTURE.js'); }; diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-do-while-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-do-while-script-code-valid.js index 1b86097b58..e667c594e0 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-do-while-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-do-while-script-code-valid.js @@ -27,5 +27,5 @@ var smoosh; function smoosh() {} do { - import('./script-code-valid.js'); + import('./empty_FIXTURE.js'); } while (false); diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-else-braceless-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-else-braceless-script-code-valid.js index 4426fcca22..d71f70bef9 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-else-braceless-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-else-braceless-script-code-valid.js @@ -28,4 +28,4 @@ var smoosh; function smoosh() {} if (false) { -} else import('./script-code-valid.js'); +} else import('./empty_FIXTURE.js'); diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-else-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-else-script-code-valid.js index 7ec91b881a..b621c6ff78 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-else-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-else-script-code-valid.js @@ -29,5 +29,5 @@ var smoosh; function smoosh() {} if (false) { } else { - import('./script-code-valid.js'); + import('./empty_FIXTURE.js'); } diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-function-return-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-function-return-script-code-valid.js index 5a871fa54a..0719c15fca 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-function-return-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-function-return-script-code-valid.js @@ -27,5 +27,5 @@ var smoosh; function smoosh() {} function fn() { - return import('./script-code-valid.js'); + return import('./empty_FIXTURE.js'); } diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-function-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-function-script-code-valid.js index 68f127e3e1..cdf6fc0555 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-function-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-function-script-code-valid.js @@ -27,5 +27,5 @@ var smoosh; function smoosh() {} function fn() { - import('./script-code-valid.js'); + import('./empty_FIXTURE.js'); } diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-if-braceless-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-if-braceless-script-code-valid.js index e449237b2b..b01c66b8d9 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-if-braceless-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-if-braceless-script-code-valid.js @@ -26,4 +26,4 @@ info: | var smoosh; function smoosh() {} -if (true) import('./script-code-valid.js'); +if (true) import('./empty_FIXTURE.js'); diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-if-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-if-script-code-valid.js index f2b1eb9c25..89fa4f15eb 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-if-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-if-script-code-valid.js @@ -27,5 +27,5 @@ var smoosh; function smoosh() {} if (true) { - import('./script-code-valid.js'); + import('./empty_FIXTURE.js'); } diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-while-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-while-script-code-valid.js index b196e203ea..48a0a3cb0e 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-while-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-while-script-code-valid.js @@ -29,5 +29,5 @@ var smoosh; function smoosh() {} let x = 0; while (!x) { x++; - import('./script-code-valid.js'); + import('./empty_FIXTURE.js'); }; diff --git a/test/language/module-code/dynamic-import/syntax/valid/nested-with-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/nested-with-script-code-valid.js index b46979d5ec..7334f88709 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/nested-with-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/nested-with-script-code-valid.js @@ -27,5 +27,5 @@ var smoosh; function smoosh() {} with ({}) { - import('./script-code-valid.js'); + import('./empty_FIXTURE.js'); } diff --git a/test/language/module-code/dynamic-import/syntax/valid/top-level-script-code-valid.js b/test/language/module-code/dynamic-import/syntax/valid/top-level-script-code-valid.js index 3aa54554ba..c04af7884f 100644 --- a/test/language/module-code/dynamic-import/syntax/valid/top-level-script-code-valid.js +++ b/test/language/module-code/dynamic-import/syntax/valid/top-level-script-code-valid.js @@ -16,4 +16,4 @@ info: | var smoosh; function smoosh() {} -import('./script-code-valid.js'); +import('./empty_FIXTURE.js'); diff --git a/test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000..09c4d51abc --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-arrow-assign-expr.template +/*--- +description: import() from a ascript code can load a file with module code (nested arrow) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +let f = () => import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + +}); + + +f().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-returns-thenable.js similarity index 90% rename from test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-returns-thenable.js index 463c475f53..b72f8acdf6 100644 --- a/test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-arrow-assign-expr.template /*--- -description: Dynamic import() returns a Promise object. (nested arrow) +description: Dynamic import() returns a thenable object. (nested arrow) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-specifier-tostring.js new file mode 100644 index 0000000000..3b51623c57 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-arrow-assignment-expression-specifier-tostring.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-arrow-assign-expr.template +/*--- +description: ToString value of specifier (nested arrow) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +let f = () => import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + +}); + + +f().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-arrow-import-then-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-arrow-import-then-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000..25bffd3125 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-arrow-import-then-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-arrow.template +/*--- +description: import() from a ascript code can load a file with module code (nested arrow) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +let f = () => { + return import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +}; + +f(); + diff --git a/test/language/module-code/dynamic-import/usage/nested-arrow-import-then-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-arrow-import-then-returns-thenable.js similarity index 90% rename from test/language/module-code/dynamic-import/usage/nested-arrow-import-then-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-arrow-import-then-returns-thenable.js index 0a5edbe9bc..b726b0af63 100644 --- a/test/language/module-code/dynamic-import/usage/nested-arrow-import-then-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-arrow-import-then-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-arrow.template /*--- -description: Dynamic import() returns a Promise object. (nested arrow) +description: Dynamic import() returns a thenable object. (nested arrow) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-arrow-import-then-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-arrow-import-then-specifier-tostring.js new file mode 100644 index 0000000000..442d5cf63d --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-arrow-import-then-specifier-tostring.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-arrow.template +/*--- +description: ToString value of specifier (nested arrow) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +let f = () => { + return import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +}; + +f(); + diff --git a/test/language/module-code/dynamic-import/usage/nested-async-function-await-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-async-function-await-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000..49578b5928 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-function-await-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-async-function-await.template +/*--- +description: import() from a ascript code can load a file with module code (nested in async function, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +async function f() { + await import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }); +} + +f().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-function-await-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-async-function-await-returns-thenable.js similarity index 88% rename from test/language/module-code/dynamic-import/usage/nested-async-function-await-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-async-function-await-returns-thenable.js index 065feb806f..24eb32af41 100644 --- a/test/language/module-code/dynamic-import/usage/nested-async-function-await-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-async-function-await-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-async-function-await.template /*--- -description: Dynamic import() returns a Promise object. (nested in async function, awaited) +description: Dynamic import() returns a thenable object. (nested in async function, awaited) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-async-function-await-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-async-function-await-specifier-tostring.js new file mode 100644 index 0000000000..6906ae7d56 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-function-await-specifier-tostring.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-async-function-await.template +/*--- +description: ToString value of specifier (nested in async function, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +async function f() { + await import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }); +} + +f().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-function-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-async-function-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000..71148fc8f7 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-function-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-async-function.template +/*--- +description: import() from a ascript code can load a file with module code (nested in async function) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +async function f() { + import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +} + +f(); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-function-return-await-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-async-function-return-await-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000..173933e313 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-function-return-await-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-async-function-return-await.template +/*--- +description: import() from a ascript code can load a file with module code (nested in async function, returns awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +async function f() { + return await import('./module-code_FIXTURE.js'); +} + +f().then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-function-return-await-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-async-function-return-await-returns-thenable.js similarity index 88% rename from test/language/module-code/dynamic-import/usage/nested-async-function-return-await-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-async-function-return-await-returns-thenable.js index 135a98225e..0541c60034 100644 --- a/test/language/module-code/dynamic-import/usage/nested-async-function-return-await-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-async-function-return-await-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-async-function-return-await.template /*--- -description: Dynamic import() returns a Promise object. (nested in async function, returns awaited) +description: Dynamic import() returns a thenable object. (nested in async function, returns awaited) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-async-function-return-await-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-async-function-return-await-specifier-tostring.js new file mode 100644 index 0000000000..260d2b96ba --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-function-return-await-specifier-tostring.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-async-function-return-await.template +/*--- +description: ToString value of specifier (nested in async function, returns awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +async function f() { + return await import(obj); +} + +f().then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-async-function-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-async-function-returns-thenable.js similarity index 89% rename from test/language/module-code/dynamic-import/usage/nested-async-function-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-async-function-returns-thenable.js index 435b3e0d3e..943efb3acd 100644 --- a/test/language/module-code/dynamic-import/usage/nested-async-function-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-async-function-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-async-function.template /*--- -description: Dynamic import() returns a Promise object. (nested in async function) +description: Dynamic import() returns a thenable object. (nested in async function) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-async-function-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-async-function-specifier-tostring.js new file mode 100644 index 0000000000..8ee53673db --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-async-function-specifier-tostring.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-async-function.template +/*--- +description: ToString value of specifier (nested in async function) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +async function f() { + import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +} + +f(); diff --git a/test/language/module-code/dynamic-import/usage/nested-block-import-then-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-block-import-then-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000..73047f13b4 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-block-import-then-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-block.template +/*--- +description: import() from a ascript code can load a file with module code (nested block) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +{ + import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +}; diff --git a/test/language/module-code/dynamic-import/usage/nested-block-import-then-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-block-import-then-returns-thenable.js similarity index 90% rename from test/language/module-code/dynamic-import/usage/nested-block-import-then-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-block-import-then-returns-thenable.js index 997722f966..a5340ac60c 100644 --- a/test/language/module-code/dynamic-import/usage/nested-block-import-then-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-block-import-then-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-block.template /*--- -description: Dynamic import() returns a Promise object. (nested block) +description: Dynamic import() returns a thenable object. (nested block) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-block-import-then-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-block-import-then-specifier-tostring.js new file mode 100644 index 0000000000..73d4238486 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-block-import-then-specifier-tostring.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-block.template +/*--- +description: ToString value of specifier (nested block) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +{ + import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +}; diff --git a/test/language/module-code/dynamic-import/usage/nested-do-while-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-do-while-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000..0d03d24fac --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-do-while-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-do-while.template +/*--- +description: import() from a ascript code can load a file with module code (nested do while syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +do { + import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +} while (false); diff --git a/test/language/module-code/dynamic-import/usage/nested-do-while-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-do-while-returns-thenable.js similarity index 89% rename from test/language/module-code/dynamic-import/usage/nested-do-while-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-do-while-returns-thenable.js index 1907481f2c..7cd332dd3c 100644 --- a/test/language/module-code/dynamic-import/usage/nested-do-while-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-do-while-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-do-while.template /*--- -description: Dynamic import() returns a Promise object. (nested do while syntax) +description: Dynamic import() returns a thenable object. (nested do while syntax) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-do-while-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-do-while-specifier-tostring.js new file mode 100644 index 0000000000..e352bbdffa --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-do-while-specifier-tostring.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-do-while.template +/*--- +description: ToString value of specifier (nested do while syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +do { + import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +} while (false); diff --git a/test/language/module-code/dynamic-import/usage/nested-else-import-then-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-else-import-then-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000..fd0ba3df2c --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-else-import-then-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-else.template +/*--- +description: import() from a ascript code can load a file with module code (nested else) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +if (false) { + +} else { + import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +} diff --git a/test/language/module-code/dynamic-import/usage/nested-else-import-then-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-else-import-then-returns-thenable.js similarity index 90% rename from test/language/module-code/dynamic-import/usage/nested-else-import-then-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-else-import-then-returns-thenable.js index afde7ff219..b3d67e51e9 100644 --- a/test/language/module-code/dynamic-import/usage/nested-else-import-then-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-else-import-then-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-else.template /*--- -description: Dynamic import() returns a Promise object. (nested else) +description: Dynamic import() returns a thenable object. (nested else) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-else-import-then-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-else-import-then-specifier-tostring.js new file mode 100644 index 0000000000..e30494dbd9 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-else-import-then-specifier-tostring.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-else.template +/*--- +description: ToString value of specifier (nested else) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +if (false) { + +} else { + import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +} diff --git a/test/language/module-code/dynamic-import/usage/nested-function-import-then-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-function-import-then-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000..1c5d97e525 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-function-import-then-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-function.template +/*--- +description: import() from a ascript code can load a file with module code (nested function) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +function f() { + import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +} +f(); diff --git a/test/language/module-code/dynamic-import/usage/nested-function-import-then-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-function-import-then-returns-thenable.js similarity index 90% rename from test/language/module-code/dynamic-import/usage/nested-function-import-then-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-function-import-then-returns-thenable.js index ab2ff9bfa3..53883c1866 100644 --- a/test/language/module-code/dynamic-import/usage/nested-function-import-then-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-function-import-then-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-function.template /*--- -description: Dynamic import() returns a Promise object. (nested function) +description: Dynamic import() returns a thenable object. (nested function) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-function-import-then-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-function-import-then-specifier-tostring.js new file mode 100644 index 0000000000..49178a51de --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-function-import-then-specifier-tostring.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-function.template +/*--- +description: ToString value of specifier (nested function) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +function f() { + import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +} +f(); diff --git a/test/language/module-code/dynamic-import/usage/nested-if-braceless-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-if-braceless-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000..e41cca7565 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-if-braceless-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-if-braceless.template +/*--- +description: import() from a ascript code can load a file with module code (nested if syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +if (true) import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-if-braceless-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-if-braceless-returns-thenable.js similarity index 89% rename from test/language/module-code/dynamic-import/usage/nested-if-braceless-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-if-braceless-returns-thenable.js index 37710f3aad..1701a0f191 100644 --- a/test/language/module-code/dynamic-import/usage/nested-if-braceless-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-if-braceless-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-if-braceless.template /*--- -description: Dynamic import() returns a Promise object. (nested if syntax) +description: Dynamic import() returns a thenable object. (nested if syntax) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-if-braceless-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-if-braceless-specifier-tostring.js new file mode 100644 index 0000000000..b41dd64029 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-if-braceless-specifier-tostring.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-if-braceless.template +/*--- +description: ToString value of specifier (nested if syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +if (true) import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/nested-if-import-then-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-if-import-then-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000..2c0d6ca1cd --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-if-import-then-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-if.template +/*--- +description: import() from a ascript code can load a file with module code (nested if) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +if (true) { + import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +} diff --git a/test/language/module-code/dynamic-import/usage/nested-if-import-then-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-if-import-then-returns-thenable.js similarity index 90% rename from test/language/module-code/dynamic-import/usage/nested-if-import-then-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-if-import-then-returns-thenable.js index 57f9e7dc83..e16fce3637 100644 --- a/test/language/module-code/dynamic-import/usage/nested-if-import-then-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-if-import-then-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-if.template /*--- -description: Dynamic import() returns a Promise object. (nested if) +description: Dynamic import() returns a thenable object. (nested if) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-if-import-then-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-if-import-then-specifier-tostring.js new file mode 100644 index 0000000000..44e2a5cb53 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-if-import-then-specifier-tostring.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-if.template +/*--- +description: ToString value of specifier (nested if) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +if (true) { + import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +} diff --git a/test/language/module-code/dynamic-import/usage/nested-while-import-then-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/nested-while-import-then-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000..0fb62b6e7f --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-while-import-then-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-while.template +/*--- +description: import() from a ascript code can load a file with module code (nested while) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +let x = 0; +while (!x) { + x++; + import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +}; diff --git a/test/language/module-code/dynamic-import/usage/nested-while-import-then-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-while-import-then-returns-thenable.js similarity index 90% rename from test/language/module-code/dynamic-import/usage/nested-while-import-then-returns-promise.js rename to test/language/module-code/dynamic-import/usage/nested-while-import-then-returns-thenable.js index f4bef3e87b..2d6ae02f6b 100644 --- a/test/language/module-code/dynamic-import/usage/nested-while-import-then-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/nested-while-import-then-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-while.template /*--- -description: Dynamic import() returns a Promise object. (nested while) +description: Dynamic import() returns a thenable object. (nested while) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/nested-while-import-then-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/nested-while-import-then-specifier-tostring.js new file mode 100644 index 0000000000..749504ffc1 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/nested-while-import-then-specifier-tostring.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-while.template +/*--- +description: ToString value of specifier (nested while) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +let x = 0; +while (!x) { + x++; + import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +}; diff --git a/test/language/module-code/dynamic-import/usage/nested-with-import-then-eval-gtbndng-indirect-update-dflt.js b/test/language/module-code/dynamic-import/usage/nested-with-import-then-eval-gtbndng-indirect-update-dflt.js deleted file mode 100644 index c8232adb17..0000000000 --- a/test/language/module-code/dynamic-import/usage/nested-with-import-then-eval-gtbndng-indirect-update-dflt.js +++ /dev/null @@ -1,44 +0,0 @@ -// This file was procedurally generated from the following sources: -// - src/dynamic-import/eval-gtbndng-indirect-update-dflt.case -// - src/dynamic-import/default/nested-with.template -/*--- -description: Modifications to default binding that occur after dependency has been evaluated are reflected in local binding (nested with) -esid: sec-import-call-runtime-semantics-evaluation -features: [dynamic-import] -flags: [generated, async, noStrict] -info: | - ImportCall : - import( AssignmentExpression ) - - 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). - 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). - 3. Let argRef be the result of evaluating AssignmentExpression. - 4. Let specifier be ? GetValue(argRef). - 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). - 6. Let specifierString be ToString(specifier). - 7. IfAbruptRejectPromise(specifierString, promiseCapability). - 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). - 9. Return promiseCapability.[[Promise]]. - - - GetBindingValue (N, S) - - [...] - 3. If the binding for N is an indirect binding, then - a. Let M and N2 be the indirection values provided when this binding for - N was created. - b. Let targetEnv be M.[[Environment]]. - c. If targetEnv is undefined, throw a ReferenceError exception. - d. Let targetER be targetEnv's EnvironmentRecord. - e. Return ? targetER.GetBindingValue(N2, S). - ----*/ - -with ({}) { - import('./eval-gtbndng-indirect-update-dflt_FIXTURE.js').then(imported => { - - assert.sameValue(imported.default(), 1); - assert.sameValue(imported.default, 2); - - }).then($DONE, $DONE).catch($DONE); -} diff --git a/test/language/module-code/dynamic-import/usage/nested-with-import-then-eval-gtbndng-indirect-update.js b/test/language/module-code/dynamic-import/usage/nested-with-import-then-eval-gtbndng-indirect-update.js deleted file mode 100644 index d39cd5cfae..0000000000 --- a/test/language/module-code/dynamic-import/usage/nested-with-import-then-eval-gtbndng-indirect-update.js +++ /dev/null @@ -1,52 +0,0 @@ -// This file was procedurally generated from the following sources: -// - src/dynamic-import/eval-gtbndng-indirect-update.case -// - src/dynamic-import/default/nested-with.template -/*--- -description: Modifications to named bindings that occur after dependency has been evaluated are reflected in local binding (nested with) -esid: sec-import-call-runtime-semantics-evaluation -features: [dynamic-import] -flags: [generated, async, noStrict] -includes: [fnGlobalObject.js] -info: | - ImportCall : - import( AssignmentExpression ) - - 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). - 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). - 3. Let argRef be the result of evaluating AssignmentExpression. - 4. Let specifier be ? GetValue(argRef). - 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). - 6. Let specifierString be ToString(specifier). - 7. IfAbruptRejectPromise(specifierString, promiseCapability). - 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). - 9. Return promiseCapability.[[Promise]]. - - - GetBindingValue (N, S) - - [...] - 3. If the binding for N is an indirect binding, then - a. Let M and N2 be the indirection values provided when this binding for - N was created. - b. Let targetEnv be M.[[Environment]]. - c. If targetEnv is undefined, throw a ReferenceError exception. - d. Let targetER be targetEnv's EnvironmentRecord. - e. Return ? targetER.GetBindingValue(N2, S). - ----*/ - -with ({}) { - import('./eval-gtbndng-indirect-update_FIXTURE.js').then(imported => { - - assert.sameValue(imported.x, 1); - - // This function is exposed on the global scope (instead of as an exported - // binding) in order to avoid possible false positives from assuming correct - // behavior of the semantics under test. - fnGlobalObject().test262update(); - - assert.sameValue(imported.x, 2); - - - }).then($DONE, $DONE).catch($DONE); -} diff --git a/test/language/module-code/dynamic-import/usage/nested-with-import-then-is-call-expression-square-brackets.js b/test/language/module-code/dynamic-import/usage/nested-with-import-then-is-call-expression-square-brackets.js deleted file mode 100644 index 18d95fe17a..0000000000 --- a/test/language/module-code/dynamic-import/usage/nested-with-import-then-is-call-expression-square-brackets.js +++ /dev/null @@ -1,31 +0,0 @@ -// This file was procedurally generated from the following sources: -// - src/dynamic-import/is-call-expression-square-brackets.case -// - src/dynamic-import/default/nested-with.template -/*--- -description: ImportCall is a CallExpression, it can be followed by square brackets (nested with) -esid: sec-import-call-runtime-semantics-evaluation -features: [dynamic-import] -flags: [generated, async, noStrict] -info: | - ImportCall : - import( AssignmentExpression ) - - 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). - 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). - 3. Let argRef be the result of evaluating AssignmentExpression. - 4. Let specifier be ? GetValue(argRef). - 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). - 6. Let specifierString be ToString(specifier). - 7. IfAbruptRejectPromise(specifierString, promiseCapability). - 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). - 9. Return promiseCapability.[[Promise]]. - ----*/ - -with ({}) { - import('./dynamic-import-module_FIXTURE.js')['then'](x => x).then(imported => { - - assert.sameValue(imported.x, 1); - - }).then($DONE, $DONE).catch($DONE); -} diff --git a/test/language/module-code/dynamic-import/usage/nested-with-import-then-returns-promise.js b/test/language/module-code/dynamic-import/usage/nested-with-import-then-returns-promise.js deleted file mode 100644 index 0b17dd7aeb..0000000000 --- a/test/language/module-code/dynamic-import/usage/nested-with-import-then-returns-promise.js +++ /dev/null @@ -1,31 +0,0 @@ -// This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case -// - src/dynamic-import/default/nested-with.template -/*--- -description: Dynamic import() returns a Promise object. (nested with) -esid: sec-import-call-runtime-semantics-evaluation -features: [dynamic-import] -flags: [generated, async, noStrict] -info: | - ImportCall : - import( AssignmentExpression ) - - 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). - 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). - 3. Let argRef be the result of evaluating AssignmentExpression. - 4. Let specifier be ? GetValue(argRef). - 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). - 6. Let specifierString be ToString(specifier). - 7. IfAbruptRejectPromise(specifierString, promiseCapability). - 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). - 9. Return promiseCapability.[[Promise]]. - ----*/ - -with ({}) { - import('./dynamic-import-module_FIXTURE.js').then(imported => { - - assert.sameValue(imported.x, 1); - - }).then($DONE, $DONE).catch($DONE); -} diff --git a/test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000..de78996dd4 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/nested-block-labeled.template +/*--- +description: import() from a ascript code can load a file with module code (nested block syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +label: { + import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +}; diff --git a/test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-returns-promise.js b/test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-returns-thenable.js similarity index 89% rename from test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-returns-promise.js rename to test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-returns-thenable.js index 877e77c22e..9eae36c213 100644 --- a/test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/nested-block-labeled.template /*--- -description: Dynamic import() returns a Promise object. (nested block syntax) +description: Dynamic import() returns a thenable object. (nested block syntax) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-specifier-tostring.js new file mode 100644 index 0000000000..e784c53fc3 --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/syntax-nested-block-labeled-specifier-tostring.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/nested-block-labeled.template +/*--- +description: ToString value of specifier (nested block syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +label: { + import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + + }).then($DONE, $DONE).catch($DONE); +}; diff --git a/test/language/module-code/dynamic-import/usage/top-level-import-then-eval-script-code-host-resolves-module-code.js b/test/language/module-code/dynamic-import/usage/top-level-import-then-eval-script-code-host-resolves-module-code.js new file mode 100644 index 0000000000..e8e6f7578b --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/top-level-import-then-eval-script-code-host-resolves-module-code.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/eval-script-code-host-resolves-module-code.case +// - src/dynamic-import/default/top-level.template +/*--- +description: import() from a ascript code can load a file with module code (top level) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +---*/ +// This is still valid in script code, and should not be valid for module code +// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames +var smoosh; function smoosh() {} + + +import('./module-code_FIXTURE.js').then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/usage/top-level-import-then-returns-promise.js b/test/language/module-code/dynamic-import/usage/top-level-import-then-returns-thenable.js similarity index 90% rename from test/language/module-code/dynamic-import/usage/top-level-import-then-returns-promise.js rename to test/language/module-code/dynamic-import/usage/top-level-import-then-returns-thenable.js index 626bc97eda..ea980190d4 100644 --- a/test/language/module-code/dynamic-import/usage/top-level-import-then-returns-promise.js +++ b/test/language/module-code/dynamic-import/usage/top-level-import-then-returns-thenable.js @@ -1,8 +1,8 @@ // This file was procedurally generated from the following sources: -// - src/dynamic-import/returns-promise.case +// - src/dynamic-import/returns-thenable.case // - src/dynamic-import/default/top-level.template /*--- -description: Dynamic import() returns a Promise object. (top level) +description: Dynamic import() returns a thenable object. (top level) esid: sec-import-call-runtime-semantics-evaluation features: [dynamic-import] flags: [generated, async] diff --git a/test/language/module-code/dynamic-import/usage/top-level-import-then-specifier-tostring.js b/test/language/module-code/dynamic-import/usage/top-level-import-then-specifier-tostring.js new file mode 100644 index 0000000000..41db37522a --- /dev/null +++ b/test/language/module-code/dynamic-import/usage/top-level-import-then-specifier-tostring.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/specifier-tostring.case +// - src/dynamic-import/default/top-level.template +/*--- +description: ToString value of specifier (top level) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, async] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + Import Calls + + Runtime Semantics: Evaluation + + ImportCall : import(AssignmentExpression) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let argRef be the result of evaluating AssignmentExpression. + 3. Let specifier be ? GetValue(argRef). + 4. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 5. Let specifierString be ToString(specifier). + 6. IfAbruptRejectPromise(specifierString, promiseCapability). + 7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 8. Return promiseCapability.[[Promise]]. + +---*/ +const obj = { + toString() { + return './module-code_FIXTURE.js'; + } +}; + + +import(obj).then(imported => { + + assert.sameValue(imported.default, 42); + assert.sameValue(imported.x, 'Test262'); + assert.sameValue(imported.z, 42); + +}).then($DONE, $DONE).catch($DONE); -- GitLab