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 0000000000000000000000000000000000000000..fa6011eea39264a1a87da7e6c2a55f98384661d0 --- /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 0000000000000000000000000000000000000000..c5ed7e5264bd5d8383707039c6476c24785ed7a4 --- /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 0000000000000000000000000000000000000000..94703c2121f8ecfdc113b93667fbe8a6e5080753 --- /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 0000000000000000000000000000000000000000..64e013be1139d6df57e9896a5f07f611a1fa0fa3 --- /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 0000000000000000000000000000000000000000..c2b5b19daa3f8fa760d23135f83305f00b1ca412 --- /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 0000000000000000000000000000000000000000..f63156e9e05b6accfb88393376c195f2bd88acae --- /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 0000000000000000000000000000000000000000..f3ec1bfb54beed4166d0784fedaade780a3cd221 --- /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 0000000000000000000000000000000000000000..70e3352eb050b56ff712439ce1b0e8edf761f0d5 --- /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 0000000000000000000000000000000000000000..aa11268fa662ce220c2f50b7f031d8848d3b4214 --- /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 0000000000000000000000000000000000000000..4a6398c76813798fa03082c2b66a32984e35d793 --- /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 0000000000000000000000000000000000000000..7beb7101b1536c289dc840dad5e651e79afab60b --- /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 0000000000000000000000000000000000000000..b6723a7059f8a8c68b3c9fc5acf945dea137d245 --- /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 0000000000000000000000000000000000000000..4fd908472d72c05ecace144cd30530a27842b95d --- /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 0000000000000000000000000000000000000000..7525280a08ee899e95f1f96e10578b02ba2ad89f --- /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 0000000000000000000000000000000000000000..001ff761a674d5bcf3212ffff202e00bba1cdb58 --- /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 0000000000000000000000000000000000000000..6d8e0223ba858418d442591ac4bf57218a319a7d --- /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 0000000000000000000000000000000000000000..f1f8d81cb3842dd0fc01357d5aece3a830881921 --- /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 0000000000000000000000000000000000000000..1917a05566fd078cbabf3a55b926c6acaf78c2b3 --- /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 0000000000000000000000000000000000000000..86a7e0250f769fdc7351640f2890727f9972fd07 --- /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 0000000000000000000000000000000000000000..eca30e05e09ccc1916c437903865ce1bf062e584 --- /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 0000000000000000000000000000000000000000..8676fd92c463a12c9de75dcc77f465dc5641d1c7 --- /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 0000000000000000000000000000000000000000..ddf0987e06e2e97f472dc024a29e8a7cd56515b2 --- /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 0000000000000000000000000000000000000000..daae4c13fe9c09f804dbec4e601b6e96c36ebf7d --- /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 0000000000000000000000000000000000000000..02ecae37f56e321939c45ba71605d056a208e7ef --- /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 c5654cd220ed217ebd15905f56603a0ba4ea4eb5..c2f9ad358fadf086bd89df47e42cd055406149bf 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 590fff106f11f7420c7d250f1c75fafc2744bc3a..d0b96c3678d40424300961254abab1cba840ab63 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 90849fabfe36863028cc816da16777c3e39294e9..111ba41252ed189bed1c9a8d02ea24f1ce28537c 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 f383065913465092cae33b5087905c9dda67a470..94225d612051d4d4126e57b51468c8df85ccd116 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 e00d0a7ffdbee48c09c9720e89bac53769e3642d..9b28f3564e95a193cdc8e8ce129bb204f6c757e1 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 0d36b64b70dfa0ac40d4c526a77ab500fe23df04..cce923e15e57cf37b55e7973d00cc8e0794ac69c 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 f66e994bd06829810b0b4e055b3e763e8a34d2f7..5cad7f4698115bb91f38c3f45501c6012aab6959 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 1b86097b58448ff3c7753d407d73671eebfddde8..e667c594e0eefa59014b537c5ca00828574228c8 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 4426fcca22c2f01099eeb0b30d6f7fdebb8bf3bf..d71f70bef950bbe052951ef5d259c9760feb414a 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 7ec91b881a30c0e613df73ee46c0f614de8cc54d..b621c6ff78df0729f94a6ced5fef92dae5dce075 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 5a871fa54affccb9904dfa1c223a67a2166af329..0719c15fcabd287b069138cf176ec07e86c152e3 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 68f127e3e1cca5086619bc951bcbba3a0ba810ce..cdf6fc0555fd186444b95604093a087b0f781a65 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 e449237b2bda8b69acfe6e6a26150343a1d6c026..b01c66b8d9c22b460fb4c91339e3d4969a8cfb2c 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 f2b1eb9c25604ec66ef58e3e99feb131fb8ecc36..89fa4f15eb37ed963435440e8aba6e939d51112c 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 b196e203ea4a0deda6c4e8bd38e6e0199c3605ca..48a0a3cb0e694fafe78c9b19bf0a0cb47ae05de1 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 b46979d5ece4dd73928d0143dc618b20f8497531..7334f8870994d9a8e0def64e36439304a44b2654 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 3aa54554ba511e998e9dacecae48ce53688ee0af..c04af7884fd62039d1a70fedc6cf4b6c1957729e 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 0000000000000000000000000000000000000000..09c4d51abce9c398c648d11717c73c752f490fe5 --- /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 463c475f53724b019709e4856bfc36641bc327e9..b72f8acdf6fe24296f9d0aab409f07dbfe82af6f 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 0000000000000000000000000000000000000000..3b51623c57a54572b99736896d3332a5f9ece312 --- /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 0000000000000000000000000000000000000000..25bffd31256a7d25e44af199764795870c8c1f5a --- /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 0a5edbe9bccf23438a17ab545d31150c827061cb..b726b0af63c90b9ab7601d27ccb43f0de6304ea0 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 0000000000000000000000000000000000000000..442d5cf63da57c9e53f4eb705dc7ac94486c787e --- /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 0000000000000000000000000000000000000000..49578b592815fd46b8ee5cdb25cfc35e146ac980 --- /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 065feb806fa2ed1f4034ebb27354298a9c7ce58e..24eb32af4155aa1a39e6184a89fa48450c7cf06b 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 0000000000000000000000000000000000000000..6906ae7d56366cb0dd474ff1380f05f64777b8a0 --- /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 0000000000000000000000000000000000000000..71148fc8f78a9731887fac55d242a1295c7118d9 --- /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 0000000000000000000000000000000000000000..173933e313c258c8bb78cec7e5e2ac2fea109a6b --- /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 135a98225e975281d617ec4033a0f1fb9093a75b..0541c60034161e0d3772deb364503d0c68356fc5 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 0000000000000000000000000000000000000000..260d2b96bac606eeca8adb1fbdc46acbef07dc18 --- /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 435b3e0d3eb044510e3070e31f343716ef6fa31d..943efb3acd4b3c5148ee44bc4ad89f53da7f1dbb 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 0000000000000000000000000000000000000000..8ee53673dbc987698798fa6d38fcb1a9dba5ad7a --- /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 0000000000000000000000000000000000000000..73047f13b4957fedc733cf58afadcb03b98d9bf7 --- /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 997722f9668ee1ebd35ca7b83f83f1bf843dae55..a5340ac60c210ccfaf279350838f54ff49b16406 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 0000000000000000000000000000000000000000..73d423848635fd966ffc8998a569b70f20c873c1 --- /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 0000000000000000000000000000000000000000..0d03d24facf791a98ad10b1ff9dd86d0fdcdcd3d --- /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 1907481f2c7c9c4f6b71720e75f5584242c33c92..7cd332dd3cf84631494fb2af59293de74e0915a1 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 0000000000000000000000000000000000000000..e352bbdffaa075462161ba9704bc57da046dd0b4 --- /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 0000000000000000000000000000000000000000..fd0ba3df2c8bc75bfee0e65ea9065b6df9d04972 --- /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 afde7ff219eaa66bea140f856f66813b2858e637..b3d67e51e90989fe0f0e980ca7374065e8f182d0 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 0000000000000000000000000000000000000000..e30494dbd925f2decee20947b0ddd655f63910c5 --- /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 0000000000000000000000000000000000000000..1c5d97e5254589af90cc2d6d7ae4511a443bdea3 --- /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 ab2ff9bfa3be3c3ceb2c9e59109e62a4a0a9770f..53883c18667be8169aa7577f1195d6053462f256 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 0000000000000000000000000000000000000000..49178a51de8053f3432e7df5c769fe3dd4d20f6a --- /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 0000000000000000000000000000000000000000..e41cca756593216e86774302023150f2fdd25cf3 --- /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 37710f3aadb0cd19abfefcdf278f0f821819b7a3..1701a0f191a992ad43b25ffa4d0629458fdf427d 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 0000000000000000000000000000000000000000..b41dd6402936454dd34bd61a96ce419c107b3c94 --- /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 0000000000000000000000000000000000000000..2c0d6ca1cde98f3140363ea07f964969404d9723 --- /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 57f9e7dc83a69a7a2a5f2b738859ab379f739e87..e16fce36373fc0a19c97910bd6a82f060f6d4c72 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 0000000000000000000000000000000000000000..44e2a5cb53ea1396d604309777e22a45ff6fbe55 --- /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 0000000000000000000000000000000000000000..0fb62b6e7f180b2704e8c31034e4cdd2fa8baa29 --- /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 f4bef3e87ba6de20c56a7be2dc867d45b39fb916..2d6ae02f6b0da775c8e055eb1f3f0614e6e34817 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 0000000000000000000000000000000000000000..749504ffc1e2c6371f0cf41f134dfbf7ff4299e8 --- /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 c8232adb174dd330d35422d8895e1936526e2297..0000000000000000000000000000000000000000 --- 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 d39cd5cfae154f07f8b7e2c772830746a2f6df13..0000000000000000000000000000000000000000 --- 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 18d95fe17a03710c9b404dae042b7b2b6c937b3b..0000000000000000000000000000000000000000 --- 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 0b17dd7aeba79e0c5327e6d1b488e175506bb4f3..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..de78996dd46a85a085eff0765369c491f4713090 --- /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 877e77c22e6389ac939904e188fb49b447ab90da..9eae36c213f0bc2dca2ceb3f2246d199e8b71e94 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 0000000000000000000000000000000000000000..e784c53fc35af8aa5f1324d18c9dbd2db682519a --- /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 0000000000000000000000000000000000000000..e8e6f7578beb548acf562536478df966f9eabc0f --- /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 626bc97edaf199f7e2110e7883a61aff53a32c0c..ea980190d4aed159f44cbc3beb173f6e150f9872 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 0000000000000000000000000000000000000000..41db37522a334acb15de1ba4e2483b7c4c9e91d0 --- /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);