From c77078809c2861191aafc4aa6b6e4564a2a0b007 Mon Sep 17 00:00:00 2001 From: Rick Waldron <waldron.rick@gmail.com> Date: Tue, 5 Jun 2018 14:17:20 -0400 Subject: [PATCH] Dynamic Imports: initial cases, templates, non-generated tests and fixtures --- features.txt | 4 ++ .../catch/nested-arrow.template | 34 +++++++++++++++ .../nested-async-function-await.template | 34 +++++++++++++++ ...ested-async-function-return-await.template | 34 +++++++++++++++ .../catch/nested-async-function.template | 35 ++++++++++++++++ .../catch/nested-block-labeled.template | 32 +++++++++++++++ .../catch/nested-block.template | 32 +++++++++++++++ .../catch/nested-do-while.template | 32 +++++++++++++++ src/dynamic-import/catch/nested-do.template | 34 +++++++++++++++ src/dynamic-import/catch/nested-else.template | 34 +++++++++++++++ .../catch/nested-function.template | 33 +++++++++++++++ src/dynamic-import/catch/nested-if.template | 32 +++++++++++++++ .../catch/nested-labeled-block.template | 32 +++++++++++++++ .../catch/nested-while.template | 34 +++++++++++++++ src/dynamic-import/catch/top-level.template | 30 ++++++++++++++ ...ested-arrow-assignment-expression.template | 33 +++++++++++++++ .../default/nested-arrow.template | 35 ++++++++++++++++ .../nested-async-function-await.template | 34 +++++++++++++++ ...ested-async-function-return-await.template | 34 +++++++++++++++ .../default/nested-async-function.template | 35 ++++++++++++++++ .../default/nested-block-labeled.template | 32 +++++++++++++++ .../default/nested-block.template | 32 +++++++++++++++ .../default/nested-do-while.template | 32 +++++++++++++++ src/dynamic-import/default/nested-do.template | 34 +++++++++++++++ .../default/nested-else.template | 34 +++++++++++++++ .../default/nested-function.template | 33 +++++++++++++++ .../default/nested-if-braceless.template | 26 ++++++++++++ src/dynamic-import/default/nested-if.template | 32 +++++++++++++++ .../default/nested-labeled-block.template | 32 +++++++++++++++ .../default/nested-while.template | 34 +++++++++++++++ src/dynamic-import/default/top-level.template | 30 ++++++++++++++ .../empty-args-early-error.case | 20 +++++++++ src/dynamic-import/empty-str-arg.case | 10 +++++ .../eval-gtbdng-indirect-update-as.case | 34 +++++++++++++++ .../eval-gtbdng-indirect-update-dflt.case | 28 +++++++++++++ .../eval-gtbndng-indirect-update.case | 36 ++++++++++++++++ .../eval-rqstd-abrupt-typeerror.case | 21 ++++++++++ .../eval-rqstd-abrupt-urierror.case | 21 ++++++++++ .../instn-iee-err-ambiguous-import.case | 41 +++++++++++++++++++ .../instn-iee-err-circular.case | 30 ++++++++++++++ .../instn-iee-err-not-found.case | 29 +++++++++++++ src/dynamic-import/returns-promise.case | 13 ++++++ ...ested-arrow-assignment-expression.template | 26 ++++++++++++ .../syntax/nested-arrow.template | 28 +++++++++++++ .../nested-async-function-await.template | 28 +++++++++++++ ...ested-async-function-return-await.template | 29 +++++++++++++ .../syntax/nested-async-function.template | 29 +++++++++++++ .../syntax/nested-block-labeled.template | 28 +++++++++++++ .../syntax/nested-block.template | 28 +++++++++++++ .../syntax/nested-do-while.template | 28 +++++++++++++ src/dynamic-import/syntax/nested-do.template | 30 ++++++++++++++ .../syntax/nested-else-braceless.template | 28 +++++++++++++ .../syntax/nested-else.template | 30 ++++++++++++++ .../syntax/nested-function-return.template | 28 +++++++++++++ .../syntax/nested-function.template | 28 +++++++++++++ .../syntax/nested-if-braceless.template | 26 ++++++++++++ src/dynamic-import/syntax/nested-if.template | 28 +++++++++++++ .../syntax/nested-labeled.template | 28 +++++++++++++ .../syntax/nested-while.template | 30 ++++++++++++++ src/dynamic-import/syntax/top-level.template | 16 ++++++++ .../dynamic-import-module_FIXTURE.js | 4 ++ ...eval-gtbndng-indirect-update-as_FIXTURE.js | 9 ++++ ...al-gtbndng-indirect-update-dflt_FIXTURE.js | 7 ++++ .../eval-gtbndng-indirect-update_FIXTURE.js | 9 ++++ .../eval-rqstd-abrupt-err-type_FIXTURE.js | 4 ++ .../eval-rqstd-abrupt-err-uri_FIXTURE.js | 4 ++ .../dynamic-import/eval-rqstd-once.js | 31 ++++++++++++++ .../dynamic-import/eval-rqstd-once_FIXTURE.js | 15 +++++++ .../dynamic-import/eval-self-once.js | 32 +++++++++++++++ .../instn-iee-err-ambiguous-1_FIXTURE.js | 4 ++ .../instn-iee-err-ambiguous-2_FIXTURE.js | 4 ++ .../instn-iee-err-ambiguous-export.js | 39 ++++++++++++++++++ .../instn-iee-err-ambiguous_FIXTURE.js | 5 +++ .../instn-iee-err-circular-1_FIXTURE.js | 4 ++ .../instn-iee-err-circular-2_FIXTURE.js | 4 ++ .../instn-iee-err-not-found-empty_FIXTURE.js | 4 ++ 76 files changed, 1946 insertions(+) create mode 100644 src/dynamic-import/catch/nested-arrow.template create mode 100644 src/dynamic-import/catch/nested-async-function-await.template create mode 100644 src/dynamic-import/catch/nested-async-function-return-await.template create mode 100644 src/dynamic-import/catch/nested-async-function.template create mode 100644 src/dynamic-import/catch/nested-block-labeled.template create mode 100644 src/dynamic-import/catch/nested-block.template create mode 100644 src/dynamic-import/catch/nested-do-while.template create mode 100644 src/dynamic-import/catch/nested-do.template create mode 100644 src/dynamic-import/catch/nested-else.template create mode 100644 src/dynamic-import/catch/nested-function.template create mode 100644 src/dynamic-import/catch/nested-if.template create mode 100644 src/dynamic-import/catch/nested-labeled-block.template create mode 100644 src/dynamic-import/catch/nested-while.template create mode 100644 src/dynamic-import/catch/top-level.template create mode 100644 src/dynamic-import/default/nested-arrow-assignment-expression.template create mode 100644 src/dynamic-import/default/nested-arrow.template create mode 100644 src/dynamic-import/default/nested-async-function-await.template create mode 100644 src/dynamic-import/default/nested-async-function-return-await.template create mode 100644 src/dynamic-import/default/nested-async-function.template create mode 100644 src/dynamic-import/default/nested-block-labeled.template create mode 100644 src/dynamic-import/default/nested-block.template create mode 100644 src/dynamic-import/default/nested-do-while.template create mode 100644 src/dynamic-import/default/nested-do.template create mode 100644 src/dynamic-import/default/nested-else.template create mode 100644 src/dynamic-import/default/nested-function.template create mode 100644 src/dynamic-import/default/nested-if-braceless.template create mode 100644 src/dynamic-import/default/nested-if.template create mode 100644 src/dynamic-import/default/nested-labeled-block.template create mode 100644 src/dynamic-import/default/nested-while.template create mode 100644 src/dynamic-import/default/top-level.template create mode 100644 src/dynamic-import/empty-args-early-error.case create mode 100644 src/dynamic-import/empty-str-arg.case create mode 100644 src/dynamic-import/eval-gtbdng-indirect-update-as.case create mode 100644 src/dynamic-import/eval-gtbdng-indirect-update-dflt.case create mode 100644 src/dynamic-import/eval-gtbndng-indirect-update.case create mode 100644 src/dynamic-import/eval-rqstd-abrupt-typeerror.case create mode 100644 src/dynamic-import/eval-rqstd-abrupt-urierror.case create mode 100644 src/dynamic-import/instn-iee-err-ambiguous-import.case create mode 100644 src/dynamic-import/instn-iee-err-circular.case create mode 100644 src/dynamic-import/instn-iee-err-not-found.case create mode 100644 src/dynamic-import/returns-promise.case create mode 100644 src/dynamic-import/syntax/nested-arrow-assignment-expression.template create mode 100644 src/dynamic-import/syntax/nested-arrow.template create mode 100644 src/dynamic-import/syntax/nested-async-function-await.template create mode 100644 src/dynamic-import/syntax/nested-async-function-return-await.template create mode 100644 src/dynamic-import/syntax/nested-async-function.template create mode 100644 src/dynamic-import/syntax/nested-block-labeled.template create mode 100644 src/dynamic-import/syntax/nested-block.template create mode 100644 src/dynamic-import/syntax/nested-do-while.template create mode 100644 src/dynamic-import/syntax/nested-do.template create mode 100644 src/dynamic-import/syntax/nested-else-braceless.template create mode 100644 src/dynamic-import/syntax/nested-else.template create mode 100644 src/dynamic-import/syntax/nested-function-return.template create mode 100644 src/dynamic-import/syntax/nested-function.template create mode 100644 src/dynamic-import/syntax/nested-if-braceless.template create mode 100644 src/dynamic-import/syntax/nested-if.template create mode 100644 src/dynamic-import/syntax/nested-labeled.template create mode 100644 src/dynamic-import/syntax/nested-while.template create mode 100644 src/dynamic-import/syntax/top-level.template create mode 100644 test/language/module-code/dynamic-import/dynamic-import-module_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/eval-gtbndng-indirect-update-as_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/eval-gtbndng-indirect-update-dflt_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/eval-gtbndng-indirect-update_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/eval-rqstd-abrupt-err-type_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/eval-rqstd-abrupt-err-uri_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/eval-rqstd-once.js create mode 100644 test/language/module-code/dynamic-import/eval-rqstd-once_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/eval-self-once.js create mode 100644 test/language/module-code/dynamic-import/instn-iee-err-ambiguous-1_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/instn-iee-err-ambiguous-2_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/instn-iee-err-ambiguous-export.js create mode 100644 test/language/module-code/dynamic-import/instn-iee-err-ambiguous_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/instn-iee-err-circular-1_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/instn-iee-err-circular-2_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/instn-iee-err-not-found-empty_FIXTURE.js diff --git a/features.txt b/features.txt index c254f1c6c5..63bd7d3292 100644 --- a/features.txt +++ b/features.txt @@ -30,6 +30,10 @@ class-static-methods-private # https://github.com/tc39/proposal-private-methods class-methods-private +# Dynamic Import +# https://github.com/tc39/proposal-dynamic-import +dynamic-import + # Promise.prototype.finally # https://github.com/tc39/proposal-promise-finally Promise.prototype.finally diff --git a/src/dynamic-import/catch/nested-arrow.template b/src/dynamic-import/catch/nested-arrow.template new file mode 100644 index 0000000000..366ffdcd6d --- /dev/null +++ b/src/dynamic-import/catch/nested-arrow.template @@ -0,0 +1,34 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/catch-nested-arrow-import-catch- +name: nested arrow +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +let f = () => { + import(/*{ params }*/).catch(error => { + + /*{ body }*/ + + }).then($DONE, $DONE); +}; + +f(); diff --git a/src/dynamic-import/catch/nested-async-function-await.template b/src/dynamic-import/catch/nested-async-function-await.template new file mode 100644 index 0000000000..d30e585ad8 --- /dev/null +++ b/src/dynamic-import/catch/nested-async-function-await.template @@ -0,0 +1,34 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/catch-nested-async-function-await- +name: nested in async function, awaited +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +async function f() { + await import(/*{ params }*/).catch(error => { + + /*{ body }*/ + + }).then($DONE, $DONE); +} + +f(); diff --git a/src/dynamic-import/catch/nested-async-function-return-await.template b/src/dynamic-import/catch/nested-async-function-return-await.template new file mode 100644 index 0000000000..c1faa66f12 --- /dev/null +++ b/src/dynamic-import/catch/nested-async-function-return-await.template @@ -0,0 +1,34 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/catch-nested-async-function-return-await- +name: nested in async function, returns awaited +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +async function f() { + return await import(/*{ params }*/).catch(error => { + + /*{ body }*/ + + }).then($DONE, $DONE); +} + +f(); diff --git a/src/dynamic-import/catch/nested-async-function.template b/src/dynamic-import/catch/nested-async-function.template new file mode 100644 index 0000000000..cad3c146fa --- /dev/null +++ b/src/dynamic-import/catch/nested-async-function.template @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/catch-nested-async-function- +name: nested in async function +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +async function f() { + import(/*{ params }*/).catch(error => { + + /*{ body }*/ + + }).then($DONE, $DONE); +} + +f(); + diff --git a/src/dynamic-import/catch/nested-block-labeled.template b/src/dynamic-import/catch/nested-block-labeled.template new file mode 100644 index 0000000000..22f9a6acda --- /dev/null +++ b/src/dynamic-import/catch/nested-block-labeled.template @@ -0,0 +1,32 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/catch-nested-block-labeled- +name: nested block syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +label: { + import(/*{ params }*/).catch(error => { + + /*{ body }*/ + + }).then($DONE, $DONE); +}; diff --git a/src/dynamic-import/catch/nested-block.template b/src/dynamic-import/catch/nested-block.template new file mode 100644 index 0000000000..f8c07ed8d6 --- /dev/null +++ b/src/dynamic-import/catch/nested-block.template @@ -0,0 +1,32 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/catch-nested-block-import-catch- +name: nested block +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +{ + import(/*{ params }*/).catch(error => { + + /*{ body }*/ + + }).then($DONE, $DONE); +}; diff --git a/src/dynamic-import/catch/nested-do-while.template b/src/dynamic-import/catch/nested-do-while.template new file mode 100644 index 0000000000..00a9fb26b1 --- /dev/null +++ b/src/dynamic-import/catch/nested-do-while.template @@ -0,0 +1,32 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/catch-nested-do-while- +name: nested do syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +do { + import(/*{ params }*/).catch(error => { + + /*{ body }*/ + + }).then($DONE, $DONE); +} while (false); diff --git a/src/dynamic-import/catch/nested-do.template b/src/dynamic-import/catch/nested-do.template new file mode 100644 index 0000000000..0fdec9c52e --- /dev/null +++ b/src/dynamic-import/catch/nested-do.template @@ -0,0 +1,34 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/catch-nested-do-import-catch- +name: nested do +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +let x = 0; +do { + x++; + import(/*{ params }*/).catch(error => { + + /*{ body }*/ + + }).then($DONE, $DONE); +} while (!x); diff --git a/src/dynamic-import/catch/nested-else.template b/src/dynamic-import/catch/nested-else.template new file mode 100644 index 0000000000..332187b124 --- /dev/null +++ b/src/dynamic-import/catch/nested-else.template @@ -0,0 +1,34 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/catch-nested-else-import-catch- +name: nested else +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +if (false) { + +} else { + import(/*{ params }*/).catch(error => { + + /*{ body }*/ + + }).then($DONE, $DONE); +} diff --git a/src/dynamic-import/catch/nested-function.template b/src/dynamic-import/catch/nested-function.template new file mode 100644 index 0000000000..8738d0951c --- /dev/null +++ b/src/dynamic-import/catch/nested-function.template @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/catch-nested-function-import-catch- +name: nested function +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +function f() { + import(/*{ params }*/).catch(error => { + + /*{ body }*/ + + }).then($DONE, $DONE); +} +f(); diff --git a/src/dynamic-import/catch/nested-if.template b/src/dynamic-import/catch/nested-if.template new file mode 100644 index 0000000000..a3ddc2c3d3 --- /dev/null +++ b/src/dynamic-import/catch/nested-if.template @@ -0,0 +1,32 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/catch-nested-if-import-catch- +name: nested if +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +if (true) { + import(/*{ params }*/).catch(error => { + + /*{ body }*/ + + }).then($DONE, $DONE); +} diff --git a/src/dynamic-import/catch/nested-labeled-block.template b/src/dynamic-import/catch/nested-labeled-block.template new file mode 100644 index 0000000000..deb4dcc283 --- /dev/null +++ b/src/dynamic-import/catch/nested-labeled-block.template @@ -0,0 +1,32 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/catch-nested-labeled-block-import-catch- +name: nested labeled block +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +{ + import(/*{ params }*/).catch(error => { + + /*{ body }*/ + + }).then($DONE, $DONE); +}; diff --git a/src/dynamic-import/catch/nested-while.template b/src/dynamic-import/catch/nested-while.template new file mode 100644 index 0000000000..63aeedabc9 --- /dev/null +++ b/src/dynamic-import/catch/nested-while.template @@ -0,0 +1,34 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/catch-nested-while-import-catch- +name: nested while +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +let x = 0; +while (!x) { + x++; + import(/*{ params }*/).catch(error => { + + /*{ body }*/ + + }).then($DONE, $DONE); +}; diff --git a/src/dynamic-import/catch/top-level.template b/src/dynamic-import/catch/top-level.template new file mode 100644 index 0000000000..44b6734fe2 --- /dev/null +++ b/src/dynamic-import/catch/top-level.template @@ -0,0 +1,30 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/catch-top-level-import-catch- +name: top level +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +import(/*{ params }*/).catch(error => { + + /*{ body }*/ + +}).then($DONE, $DONE); diff --git a/src/dynamic-import/default/nested-arrow-assignment-expression.template b/src/dynamic-import/default/nested-arrow-assignment-expression.template new file mode 100644 index 0000000000..91670f32a1 --- /dev/null +++ b/src/dynamic-import/default/nested-arrow-assignment-expression.template @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/nested-arrow-assignment-expression- +name: nested arrow +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +let f = () => import(/*{ params }*/).then(imported => { + + /*{ body }*/ + +}); + + +f().then($DONE, $DONE).catch($DONE); diff --git a/src/dynamic-import/default/nested-arrow.template b/src/dynamic-import/default/nested-arrow.template new file mode 100644 index 0000000000..300a417f3d --- /dev/null +++ b/src/dynamic-import/default/nested-arrow.template @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/nested-arrow-import-then- +name: nested arrow +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +let f = () => { + return import(/*{ params }*/).then(imported => { + + /*{ body }*/ + + }).then($DONE, $DONE).catch($DONE); +}; + +f(); + diff --git a/src/dynamic-import/default/nested-async-function-await.template b/src/dynamic-import/default/nested-async-function-await.template new file mode 100644 index 0000000000..2c6acf5fc0 --- /dev/null +++ b/src/dynamic-import/default/nested-async-function-await.template @@ -0,0 +1,34 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/nested-async-function-await- +name: nested in async function, awaited +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +async function f() { + await import(/*{ params }*/).then(imported => { + + /*{ body }*/ + + }).then($DONE, $DONE).catch($DONE); +} + +f(); diff --git a/src/dynamic-import/default/nested-async-function-return-await.template b/src/dynamic-import/default/nested-async-function-return-await.template new file mode 100644 index 0000000000..bc0b97f802 --- /dev/null +++ b/src/dynamic-import/default/nested-async-function-return-await.template @@ -0,0 +1,34 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/nested-async-function-return-await- +name: nested in async function, returns awaited +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +async function f() { + return await import(/*{ params }*/).then(imported => { + + /*{ body }*/ + + }).then($DONE, $DONE).catch($DONE); +} + +f(); diff --git a/src/dynamic-import/default/nested-async-function.template b/src/dynamic-import/default/nested-async-function.template new file mode 100644 index 0000000000..8f411529e2 --- /dev/null +++ b/src/dynamic-import/default/nested-async-function.template @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/nested-async-function- +name: nested in async function +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +async function f() { + import(/*{ params }*/).then(imported => { + + /*{ body }*/ + + }).then($DONE, $DONE).catch($DONE); +} + +f(); + diff --git a/src/dynamic-import/default/nested-block-labeled.template b/src/dynamic-import/default/nested-block-labeled.template new file mode 100644 index 0000000000..a08eb8c167 --- /dev/null +++ b/src/dynamic-import/default/nested-block-labeled.template @@ -0,0 +1,32 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/syntax-nested-block-labeled- +name: nested block syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +label: { + import(/*{ params }*/).then(imported => { + + /*{ body }*/ + + }).then($DONE, $DONE).catch($DONE); +}; diff --git a/src/dynamic-import/default/nested-block.template b/src/dynamic-import/default/nested-block.template new file mode 100644 index 0000000000..439d2c1632 --- /dev/null +++ b/src/dynamic-import/default/nested-block.template @@ -0,0 +1,32 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/nested-block-import-then- +name: nested block +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +{ + import(/*{ params }*/).then(imported => { + + /*{ body }*/ + + }).then($DONE, $DONE).catch($DONE); +}; diff --git a/src/dynamic-import/default/nested-do-while.template b/src/dynamic-import/default/nested-do-while.template new file mode 100644 index 0000000000..ebe232a3ce --- /dev/null +++ b/src/dynamic-import/default/nested-do-while.template @@ -0,0 +1,32 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/nested-do-while- +name: nested do syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +do { + import(/*{ params }*/).then(imported => { + + /*{ body }*/ + + }).then($DONE, $DONE).catch($DONE); +} while (false); diff --git a/src/dynamic-import/default/nested-do.template b/src/dynamic-import/default/nested-do.template new file mode 100644 index 0000000000..d6a19aae8d --- /dev/null +++ b/src/dynamic-import/default/nested-do.template @@ -0,0 +1,34 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/nested-do-import-then- +name: nested do +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +let x = 0; +do { + x++; + import(/*{ params }*/).then(imported => { + + /*{ body }*/ + + }).then($DONE, $DONE).catch($DONE); +} while (!x); diff --git a/src/dynamic-import/default/nested-else.template b/src/dynamic-import/default/nested-else.template new file mode 100644 index 0000000000..da093ff222 --- /dev/null +++ b/src/dynamic-import/default/nested-else.template @@ -0,0 +1,34 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/nested-else-import-then- +name: nested else +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +if (false) { + +} else { + import(/*{ params }*/).then(imported => { + + /*{ body }*/ + + }).then($DONE, $DONE).catch($DONE); +} diff --git a/src/dynamic-import/default/nested-function.template b/src/dynamic-import/default/nested-function.template new file mode 100644 index 0000000000..2374db50c8 --- /dev/null +++ b/src/dynamic-import/default/nested-function.template @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/nested-function-import-then- +name: nested function +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +function f() { + import(/*{ params }*/).then(imported => { + + /*{ body }*/ + + }).then($DONE, $DONE).catch($DONE); +} +f(); diff --git a/src/dynamic-import/default/nested-if-braceless.template b/src/dynamic-import/default/nested-if-braceless.template new file mode 100644 index 0000000000..c5eb7fa198 --- /dev/null +++ b/src/dynamic-import/default/nested-if-braceless.template @@ -0,0 +1,26 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/nested-if-braceless- +name: nested if syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +if (true) import(/*{ params }*/); diff --git a/src/dynamic-import/default/nested-if.template b/src/dynamic-import/default/nested-if.template new file mode 100644 index 0000000000..42cb23a071 --- /dev/null +++ b/src/dynamic-import/default/nested-if.template @@ -0,0 +1,32 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/nested-if-import-then- +name: nested if +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +if (true) { + import(/*{ params }*/).then(imported => { + + /*{ body }*/ + + }).then($DONE, $DONE).catch($DONE); +} diff --git a/src/dynamic-import/default/nested-labeled-block.template b/src/dynamic-import/default/nested-labeled-block.template new file mode 100644 index 0000000000..7888a99ae8 --- /dev/null +++ b/src/dynamic-import/default/nested-labeled-block.template @@ -0,0 +1,32 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/nested-labeled-block-import-then- +name: nested block +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +{ + import(/*{ params }*/).then(imported => { + + /*{ body }*/ + + }).then($DONE, $DONE).catch($DONE); +}; diff --git a/src/dynamic-import/default/nested-while.template b/src/dynamic-import/default/nested-while.template new file mode 100644 index 0000000000..77573a431d --- /dev/null +++ b/src/dynamic-import/default/nested-while.template @@ -0,0 +1,34 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/nested-while-import-then- +name: nested while +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +let x = 0; +while (!x) { + x++; + import(/*{ params }*/).then(imported => { + + /*{ body }*/ + + }).then($DONE, $DONE).catch($DONE); +}; diff --git a/src/dynamic-import/default/top-level.template b/src/dynamic-import/default/top-level.template new file mode 100644 index 0000000000..c0d7a1d704 --- /dev/null +++ b/src/dynamic-import/default/top-level.template @@ -0,0 +1,30 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/top-level-import-then- +name: top level +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +import(/*{ params }*/).then(imported => { + + /*{ body }*/ + +}).then($DONE, $DONE).catch($DONE); diff --git a/src/dynamic-import/empty-args-early-error.case b/src/dynamic-import/empty-args-early-error.case new file mode 100644 index 0000000000..85a880268d --- /dev/null +++ b/src/dynamic-import/empty-args-early-error.case @@ -0,0 +1,20 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: It's a SyntaxError if AssignmentExpression is omitted +template: syntax +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import() + +---*/ +//- setup +throw "Test262: This statement should not be evaluated."; +//- params + +//- teardown +/* The params region intentionally empty */ diff --git a/src/dynamic-import/empty-str-arg.case b/src/dynamic-import/empty-str-arg.case new file mode 100644 index 0000000000..9d0ae8fac2 --- /dev/null +++ b/src/dynamic-import/empty-str-arg.case @@ -0,0 +1,10 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Calling import('') +template: syntax +---*/ + +//- params +'' diff --git a/src/dynamic-import/eval-gtbdng-indirect-update-as.case b/src/dynamic-import/eval-gtbdng-indirect-update-as.case new file mode 100644 index 0000000000..d063755855 --- /dev/null +++ b/src/dynamic-import/eval-gtbdng-indirect-update-as.case @@ -0,0 +1,34 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Modifications to named bindings that occur after dependency has been + evaluated are reflected in local binding +info: | + 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). +includes: [fnGlobalObject.js] +template: default +flags: [async] +---*/ + +//- params +'./eval-gtbndng-indirect-update-as_FIXTURE.js' +//- body +assert.sameValue(imported.x, 1); + +// This function is exposed on the global scope (instead of as an imported +// binding) in order to avoid possible false positives from assuming correct +// behavior of the semantics under test. +fnGlobalObject().test262update(); + +assert.sameValue(imported.x, 2); diff --git a/src/dynamic-import/eval-gtbdng-indirect-update-dflt.case b/src/dynamic-import/eval-gtbdng-indirect-update-dflt.case new file mode 100644 index 0000000000..056e8e45ba --- /dev/null +++ b/src/dynamic-import/eval-gtbdng-indirect-update-dflt.case @@ -0,0 +1,28 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Modifications to default binding that occur after dependency has been + evaluated are reflected in local binding +info: | + 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). + +template: default +flags: [async] +---*/ + +//- params +'./eval-gtbndng-indirect-update-dflt_FIXTURE.js' +//- body +assert.sameValue(imported.default(), 1); +assert.sameValue(imported.default, 2); diff --git a/src/dynamic-import/eval-gtbndng-indirect-update.case b/src/dynamic-import/eval-gtbndng-indirect-update.case new file mode 100644 index 0000000000..c6862d3b76 --- /dev/null +++ b/src/dynamic-import/eval-gtbndng-indirect-update.case @@ -0,0 +1,36 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Modifications to named bindings that occur after dependency has been + evaluated are reflected in local binding +esid: sec-moduleevaluation +info: | + 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). +includes: [fnGlobalObject.js] +template: default +flags: [async] +---*/ + +//- params +'./eval-gtbndng-indirect-update_FIXTURE.js' +//- body +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); + diff --git a/src/dynamic-import/eval-rqstd-abrupt-typeerror.case b/src/dynamic-import/eval-rqstd-abrupt-typeerror.case new file mode 100644 index 0000000000..0629d59929 --- /dev/null +++ b/src/dynamic-import/eval-rqstd-abrupt-typeerror.case @@ -0,0 +1,21 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Abrupt completion during module evaluation precludes further evaluation +esid: sec-moduleevaluation +info: | + [...] + 6. For each String required that is an element of + module.[[RequestedModules]] do, + a. Let requiredModule be ? HostResolveImportedModule(module, required). + b. Perform ? requiredModule.ModuleEvaluation(). +template: catch +flags: [async] +---*/ + +//- params +'./eval-rqstd-abrupt-err-type_FIXTURE.js' +//- body +assert.sameValue(error.name, 'TypeError'); diff --git a/src/dynamic-import/eval-rqstd-abrupt-urierror.case b/src/dynamic-import/eval-rqstd-abrupt-urierror.case new file mode 100644 index 0000000000..1930388b55 --- /dev/null +++ b/src/dynamic-import/eval-rqstd-abrupt-urierror.case @@ -0,0 +1,21 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Abrupt completion during module evaluation precludes further evaluation +esid: sec-moduleevaluation +info: | + [...] + 6. For each String required that is an element of + module.[[RequestedModules]] do, + a. Let requiredModule be ? HostResolveImportedModule(module, required). + b. Perform ? requiredModule.ModuleEvaluation(). +template: catch +flags: [async] +---*/ + +//- params +'./eval-rqstd-abrupt-err-uri_FIXTURE.js' +//- body +assert.sameValue(error.name, 'URIError'); diff --git a/src/dynamic-import/instn-iee-err-ambiguous-import.case b/src/dynamic-import/instn-iee-err-ambiguous-import.case new file mode 100644 index 0000000000..415643b956 --- /dev/null +++ b/src/dynamic-import/instn-iee-err-ambiguous-import.case @@ -0,0 +1,41 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: IndirectExportEntries validation - ambiguous imported bindings +esid: sec-moduledeclarationinstantiation +info: | + [...] + 9. For each ExportEntry Record e in module.[[IndirectExportEntries]], do + a. Let resolution be ? module.ResolveExport(e.[[ExportName]], « », « »). + b. If resolution is null or resolution is "ambiguous", throw a + SyntaxError exception. + [...] + + 15.2.1.16.3 ResolveExport + + [...] + 9. Let starResolution be null. + 10. For each ExportEntry Record e in module.[[StarExportEntries]], do + a. Let importedModule be ? HostResolveImportedModule(module, + e.[[ModuleRequest]]). + b. Let resolution be ? importedModule.ResolveExport(exportName, + resolveSet, exportStarSet). + c. If resolution is "ambiguous", return "ambiguous". + d. If resolution is not null, then + i. If starResolution is null, let starResolution be resolution. + ii. Else, + 1. Assert: there is more than one * import that includes the + requested name. + 2. If resolution.[[Module]] and starResolution.[[Module]] are + not the same Module Record or + SameValue(resolution.[[BindingName]], + starResolution.[[BindingName]]) is false, return "ambiguous". +template: catch +flags: [async] +---*/ + +//- params +'./instn-iee-err-ambiguous-export.js' +//- body +assert.sameValue(error.name, 'SyntaxError'); diff --git a/src/dynamic-import/instn-iee-err-circular.case b/src/dynamic-import/instn-iee-err-circular.case new file mode 100644 index 0000000000..61d5ddbdab --- /dev/null +++ b/src/dynamic-import/instn-iee-err-circular.case @@ -0,0 +1,30 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: IndirectExportEntries validation - circular imported bindings +esid: sec-moduledeclarationinstantiation +info: | + [...] + 9. For each ExportEntry Record e in module.[[IndirectExportEntries]], do + a. Let resolution be ? module.ResolveExport(e.[[ExportName]], « », « »). + b. If resolution is null or resolution is "ambiguous", throw a + SyntaxError exception. + [...] + + 15.2.1.16.3 ResolveExport + + [...] + 2. For each Record {[[Module]], [[ExportName]]} r in resolveSet, do: + a. If module and r.[[Module]] are the same Module Record and + SameValue(exportName, r.[[ExportName]]) is true, then + i. Assert: this is a circular import request. + ii. Return null. +template: catch +flags: [async] +---*/ + +//- params +'./instn-iee-err-circular-1_FIXTURE.js' +//- body +assert.sameValue(error.name, 'SyntaxError'); diff --git a/src/dynamic-import/instn-iee-err-not-found.case b/src/dynamic-import/instn-iee-err-not-found.case new file mode 100644 index 0000000000..3c6b40ea97 --- /dev/null +++ b/src/dynamic-import/instn-iee-err-not-found.case @@ -0,0 +1,29 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: IndirectExportEntries validation - undefined imported bindings +esid: sec-moduledeclarationinstantiation +info: | + [...] + 9. For each ExportEntry Record e in module.[[IndirectExportEntries]], do + a. Let resolution be ? module.ResolveExport(e.[[ExportName]], « », « »). + b. If resolution is null or resolution is "ambiguous", throw a + SyntaxError exception. + [...] + + 15.2.1.16.3 ResolveExport + + [...] + 9. Let starResolution be null. + 10. For each ExportEntry Record e in module.[[StarExportEntries]], do + [...] + 11. Return starResolution. +template: catch +flags: [async] +---*/ + +//- params +'./instn-iee-err-not-found-empty_FIXTURE.js' +//- body +assert.sameValue(error.name, 'SyntaxError'); diff --git a/src/dynamic-import/returns-promise.case b/src/dynamic-import/returns-promise.case new file mode 100644 index 0000000000..84cba2a759 --- /dev/null +++ b/src/dynamic-import/returns-promise.case @@ -0,0 +1,13 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Dynamic import() returns a Promise object. +template: default +flags: [async] +---*/ + +//- params +'./dynamic-import-module_FIXTURE.js' +//- body +assert.sameValue(imported.x, 1); diff --git a/src/dynamic-import/syntax/nested-arrow-assignment-expression.template b/src/dynamic-import/syntax/nested-arrow-assignment-expression.template new file mode 100644 index 0000000000..798c194643 --- /dev/null +++ b/src/dynamic-import/syntax/nested-arrow-assignment-expression.template @@ -0,0 +1,26 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/syntax-nested-arrow-assignment-expression- +name: nested arrow syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +let f = () => import(/*{ params }*/); diff --git a/src/dynamic-import/syntax/nested-arrow.template b/src/dynamic-import/syntax/nested-arrow.template new file mode 100644 index 0000000000..5294e8f632 --- /dev/null +++ b/src/dynamic-import/syntax/nested-arrow.template @@ -0,0 +1,28 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/syntax-nested-arrow- +name: nested arrow syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +let f = () => { + import(/*{ params }*/); +}; diff --git a/src/dynamic-import/syntax/nested-async-function-await.template b/src/dynamic-import/syntax/nested-async-function-await.template new file mode 100644 index 0000000000..e52872095c --- /dev/null +++ b/src/dynamic-import/syntax/nested-async-function-await.template @@ -0,0 +1,28 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/syntax-nested-arrow- +name: nested arrow syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +async function f() { + await import(/*{ params }*/); +} diff --git a/src/dynamic-import/syntax/nested-async-function-return-await.template b/src/dynamic-import/syntax/nested-async-function-return-await.template new file mode 100644 index 0000000000..9229a80921 --- /dev/null +++ b/src/dynamic-import/syntax/nested-async-function-return-await.template @@ -0,0 +1,29 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/syntax-nested-arrow- +name: nested arrow syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +async function f() { + return await import(/*{ params }*/); +} + diff --git a/src/dynamic-import/syntax/nested-async-function.template b/src/dynamic-import/syntax/nested-async-function.template new file mode 100644 index 0000000000..e1b653a0e6 --- /dev/null +++ b/src/dynamic-import/syntax/nested-async-function.template @@ -0,0 +1,29 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/syntax-nested-arrow- +name: nested arrow syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +async function f() { + import(/*{ params }*/); +} + diff --git a/src/dynamic-import/syntax/nested-block-labeled.template b/src/dynamic-import/syntax/nested-block-labeled.template new file mode 100644 index 0000000000..c9ce939863 --- /dev/null +++ b/src/dynamic-import/syntax/nested-block-labeled.template @@ -0,0 +1,28 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/syntax-nested-block-labeled- +name: nested block syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +label: { + import(/*{ params }*/); +}; diff --git a/src/dynamic-import/syntax/nested-block.template b/src/dynamic-import/syntax/nested-block.template new file mode 100644 index 0000000000..f243b01f74 --- /dev/null +++ b/src/dynamic-import/syntax/nested-block.template @@ -0,0 +1,28 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/syntax-nested-block- +name: nested block syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +{ + import(/*{ params }*/); +}; diff --git a/src/dynamic-import/syntax/nested-do-while.template b/src/dynamic-import/syntax/nested-do-while.template new file mode 100644 index 0000000000..7526c2e7e3 --- /dev/null +++ b/src/dynamic-import/syntax/nested-do-while.template @@ -0,0 +1,28 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/syntax-nested-do-while- +name: nested do syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +do { + import(/*{ params }*/); +} while (false); diff --git a/src/dynamic-import/syntax/nested-do.template b/src/dynamic-import/syntax/nested-do.template new file mode 100644 index 0000000000..260c92e977 --- /dev/null +++ b/src/dynamic-import/syntax/nested-do.template @@ -0,0 +1,30 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/syntax-nested-do- +name: nested do syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +let x = 0; +do { + x++; + import(/*{ params }*/); +} while (!x); diff --git a/src/dynamic-import/syntax/nested-else-braceless.template b/src/dynamic-import/syntax/nested-else-braceless.template new file mode 100644 index 0000000000..a5423c88c3 --- /dev/null +++ b/src/dynamic-import/syntax/nested-else-braceless.template @@ -0,0 +1,28 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/syntax-nested-else-braceless- +name: nested else syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +if (false) { + +} else import(/*{ params }*/); diff --git a/src/dynamic-import/syntax/nested-else.template b/src/dynamic-import/syntax/nested-else.template new file mode 100644 index 0000000000..1c4893c95e --- /dev/null +++ b/src/dynamic-import/syntax/nested-else.template @@ -0,0 +1,30 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/syntax-nested-else- +name: nested else syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +if (false) { + +} else { + import(/*{ params }*/); +} diff --git a/src/dynamic-import/syntax/nested-function-return.template b/src/dynamic-import/syntax/nested-function-return.template new file mode 100644 index 0000000000..9cc9b6ed3a --- /dev/null +++ b/src/dynamic-import/syntax/nested-function-return.template @@ -0,0 +1,28 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/syntax-nested-function-return- +name: nested function syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +function fn() { + return import(/*{ params }*/); +} diff --git a/src/dynamic-import/syntax/nested-function.template b/src/dynamic-import/syntax/nested-function.template new file mode 100644 index 0000000000..44712eae6e --- /dev/null +++ b/src/dynamic-import/syntax/nested-function.template @@ -0,0 +1,28 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/syntax-nested-function- +name: nested function syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +function fn() { + import(/*{ params }*/); +} diff --git a/src/dynamic-import/syntax/nested-if-braceless.template b/src/dynamic-import/syntax/nested-if-braceless.template new file mode 100644 index 0000000000..c76fec144d --- /dev/null +++ b/src/dynamic-import/syntax/nested-if-braceless.template @@ -0,0 +1,26 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/syntax-nested-if-braceless- +name: nested if syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +if (true) import(/*{ params }*/); diff --git a/src/dynamic-import/syntax/nested-if.template b/src/dynamic-import/syntax/nested-if.template new file mode 100644 index 0000000000..bf49ff3ed5 --- /dev/null +++ b/src/dynamic-import/syntax/nested-if.template @@ -0,0 +1,28 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/syntax-nested-if- +name: nested if syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +if (true) { + import(/*{ params }*/); +} diff --git a/src/dynamic-import/syntax/nested-labeled.template b/src/dynamic-import/syntax/nested-labeled.template new file mode 100644 index 0000000000..2f8f01e9b5 --- /dev/null +++ b/src/dynamic-import/syntax/nested-labeled.template @@ -0,0 +1,28 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/syntax-nested-labeled-block- +name: nested block syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +{ + import(/*{ params }*/); +}; diff --git a/src/dynamic-import/syntax/nested-while.template b/src/dynamic-import/syntax/nested-while.template new file mode 100644 index 0000000000..4639357431 --- /dev/null +++ b/src/dynamic-import/syntax/nested-while.template @@ -0,0 +1,30 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/syntax-nested-while- +name: nested while syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + +flags: [module] +features: [dynamic-import] +---*/ + +let x = 0; +while (!x) { + x++; + import(/*{ params }*/); +}; diff --git a/src/dynamic-import/syntax/top-level.template b/src/dynamic-import/syntax/top-level.template new file mode 100644 index 0000000000..f2f43a6a1a --- /dev/null +++ b/src/dynamic-import/syntax/top-level.template @@ -0,0 +1,16 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/module-code/dynamic-import/syntax-top-level- +name: top level syntax +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall : + import( AssignmentExpression ) + +flags: [module] +features: [dynamic-import] +---*/ + +import(/*{ params }*/); diff --git a/test/language/module-code/dynamic-import/dynamic-import-module_FIXTURE.js b/test/language/module-code/dynamic-import/dynamic-import-module_FIXTURE.js new file mode 100644 index 0000000000..ef3f4207cd --- /dev/null +++ b/test/language/module-code/dynamic-import/dynamic-import-module_FIXTURE.js @@ -0,0 +1,4 @@ +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export var x = 1; diff --git a/test/language/module-code/dynamic-import/eval-gtbndng-indirect-update-as_FIXTURE.js b/test/language/module-code/dynamic-import/eval-gtbndng-indirect-update-as_FIXTURE.js new file mode 100644 index 0000000000..bd505a0210 --- /dev/null +++ b/test/language/module-code/dynamic-import/eval-gtbndng-indirect-update-as_FIXTURE.js @@ -0,0 +1,9 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +var x = 1; +export { x }; + +Function('return this;')().test262update = function() { + x = 2; +}; diff --git a/test/language/module-code/dynamic-import/eval-gtbndng-indirect-update-dflt_FIXTURE.js b/test/language/module-code/dynamic-import/eval-gtbndng-indirect-update-dflt_FIXTURE.js new file mode 100644 index 0000000000..61b27a569e --- /dev/null +++ b/test/language/module-code/dynamic-import/eval-gtbndng-indirect-update-dflt_FIXTURE.js @@ -0,0 +1,7 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export default function fn() { + fn = 2; + return 1; +} diff --git a/test/language/module-code/dynamic-import/eval-gtbndng-indirect-update_FIXTURE.js b/test/language/module-code/dynamic-import/eval-gtbndng-indirect-update_FIXTURE.js new file mode 100644 index 0000000000..bd505a0210 --- /dev/null +++ b/test/language/module-code/dynamic-import/eval-gtbndng-indirect-update_FIXTURE.js @@ -0,0 +1,9 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +var x = 1; +export { x }; + +Function('return this;')().test262update = function() { + x = 2; +}; diff --git a/test/language/module-code/dynamic-import/eval-rqstd-abrupt-err-type_FIXTURE.js b/test/language/module-code/dynamic-import/eval-rqstd-abrupt-err-type_FIXTURE.js new file mode 100644 index 0000000000..13544ca36a --- /dev/null +++ b/test/language/module-code/dynamic-import/eval-rqstd-abrupt-err-type_FIXTURE.js @@ -0,0 +1,4 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +throw new TypeError(); diff --git a/test/language/module-code/dynamic-import/eval-rqstd-abrupt-err-uri_FIXTURE.js b/test/language/module-code/dynamic-import/eval-rqstd-abrupt-err-uri_FIXTURE.js new file mode 100644 index 0000000000..3cdfc0dce7 --- /dev/null +++ b/test/language/module-code/dynamic-import/eval-rqstd-abrupt-err-uri_FIXTURE.js @@ -0,0 +1,4 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +throw new URIError(); diff --git a/test/language/module-code/dynamic-import/eval-rqstd-once.js b/test/language/module-code/dynamic-import/eval-rqstd-once.js new file mode 100644 index 0000000000..ca1a910122 --- /dev/null +++ b/test/language/module-code/dynamic-import/eval-rqstd-once.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Requested modules are evaluated exactly once +esid: sec-moduleevaluation +info: | + [...] + 4. If module.[[Evaluated]] is true, return undefined. + 5. Set module.[[Evaluated]] to true. + 6. For each String required that is an element of module.[[RequestedModules]] do, + a. Let requiredModule be ? HostResolveImportedModule(module, required). + b. Perform ? requiredModule.ModuleEvaluation(). + [...] +includes: [fnGlobalObject.js] +flags: [async, module] +features: [dynamic-import] +---*/ + +var global = fnGlobalObject(); + + + +Promise.all([ + import('./eval-rqstd-once_FIXTURE.js'), + import('./eval-rqstd-once_FIXTURE.js'), + import('./eval-rqstd-once_FIXTURE.js'), +]).then((...importeds) => { + + assert.sameValue(global.test262, 262, 'global property was defined'); + +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/eval-rqstd-once_FIXTURE.js b/test/language/module-code/dynamic-import/eval-rqstd-once_FIXTURE.js new file mode 100644 index 0000000000..8af3363daf --- /dev/null +++ b/test/language/module-code/dynamic-import/eval-rqstd-once_FIXTURE.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export default null; +var global = Function('return this;')(); + +if (global.test262) { + throw new Error('Module was evaluated more than once.'); +} + +global.test262 = 262; + +if (global.test262 !== 262) { + throw new Error('Module was unable to signal evaluation.'); +} diff --git a/test/language/module-code/dynamic-import/eval-self-once.js b/test/language/module-code/dynamic-import/eval-self-once.js new file mode 100644 index 0000000000..2dbaf6e818 --- /dev/null +++ b/test/language/module-code/dynamic-import/eval-self-once.js @@ -0,0 +1,32 @@ +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Module is evaluated exactly once +esid: sec-moduleevaluation +info: | + [...] + 4. If module.[[Evaluated]] is true, return undefined. + 5. Set module.[[Evaluated]] to true. + 6. For each String required that is an element of module.[[RequestedModules]] do, + a. Let requiredModule be ? HostResolveImportedModule(module, required). + b. Perform ? requiredModule.ModuleEvaluation(). + [...] +includes: [fnGlobalObject.js] +flags: [async,module] +features: [dynamic-import] +---*/ + +var global = fnGlobalObject(); + +if (typeof global.evaluated === 'undefined') { + global.evaluated = 0; +} + +global.evaluated++; + +Promise.all([ + import('./eval-self-once.js'), + import('./eval-self-once.js'), +]).then((...importeds) => { + assert.sameValue(global.evaluated, 1, 'global property was defined and incremented only once'); +}).then($DONE, $DONE); diff --git a/test/language/module-code/dynamic-import/instn-iee-err-ambiguous-1_FIXTURE.js b/test/language/module-code/dynamic-import/instn-iee-err-ambiguous-1_FIXTURE.js new file mode 100644 index 0000000000..896bdff50a --- /dev/null +++ b/test/language/module-code/dynamic-import/instn-iee-err-ambiguous-1_FIXTURE.js @@ -0,0 +1,4 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export var x; diff --git a/test/language/module-code/dynamic-import/instn-iee-err-ambiguous-2_FIXTURE.js b/test/language/module-code/dynamic-import/instn-iee-err-ambiguous-2_FIXTURE.js new file mode 100644 index 0000000000..896bdff50a --- /dev/null +++ b/test/language/module-code/dynamic-import/instn-iee-err-ambiguous-2_FIXTURE.js @@ -0,0 +1,4 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export var x; diff --git a/test/language/module-code/dynamic-import/instn-iee-err-ambiguous-export.js b/test/language/module-code/dynamic-import/instn-iee-err-ambiguous-export.js new file mode 100644 index 0000000000..19864dd427 --- /dev/null +++ b/test/language/module-code/dynamic-import/instn-iee-err-ambiguous-export.js @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: IndirectExportEntries validation - ambiguous imported bindings +esid: sec-moduledeclarationinstantiation +info: | + [...] + 9. For each ExportEntry Record e in module.[[IndirectExportEntries]], do + a. Let resolution be ? module.ResolveExport(e.[[ExportName]], « », « »). + b. If resolution is null or resolution is "ambiguous", throw a + SyntaxError exception. + [...] + + 15.2.1.16.3 ResolveExport + + [...] + 9. Let starResolution be null. + 10. For each ExportEntry Record e in module.[[StarExportEntries]], do + a. Let importedModule be ? HostResolveImportedModule(module, + e.[[ModuleRequest]]). + b. Let resolution be ? importedModule.ResolveExport(exportName, + resolveSet, exportStarSet). + c. If resolution is "ambiguous", return "ambiguous". + d. If resolution is not null, then + i. If starResolution is null, let starResolution be resolution. + ii. Else, + 1. Assert: there is more than one * import that includes the + requested name. + 2. If resolution.[[Module]] and starResolution.[[Module]] are + not the same Module Record or + SameValue(resolution.[[BindingName]], + starResolution.[[BindingName]]) is false, return "ambiguous". +negative: + phase: runtime + type: SyntaxError +flags: [module] +---*/ + +export { x } from './instn-iee-err-ambiguous_FIXTURE.js'; diff --git a/test/language/module-code/dynamic-import/instn-iee-err-ambiguous_FIXTURE.js b/test/language/module-code/dynamic-import/instn-iee-err-ambiguous_FIXTURE.js new file mode 100644 index 0000000000..7857161c3a --- /dev/null +++ b/test/language/module-code/dynamic-import/instn-iee-err-ambiguous_FIXTURE.js @@ -0,0 +1,5 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export * from './instn-iee-err-ambiguous-1_FIXTURE.js'; +export * from './instn-iee-err-ambiguous-2_FIXTURE.js'; diff --git a/test/language/module-code/dynamic-import/instn-iee-err-circular-1_FIXTURE.js b/test/language/module-code/dynamic-import/instn-iee-err-circular-1_FIXTURE.js new file mode 100644 index 0000000000..b4a127bfb5 --- /dev/null +++ b/test/language/module-code/dynamic-import/instn-iee-err-circular-1_FIXTURE.js @@ -0,0 +1,4 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export { x } from './instn-iee-err-circular-2_FIXTURE.js'; diff --git a/test/language/module-code/dynamic-import/instn-iee-err-circular-2_FIXTURE.js b/test/language/module-code/dynamic-import/instn-iee-err-circular-2_FIXTURE.js new file mode 100644 index 0000000000..77f5277dfc --- /dev/null +++ b/test/language/module-code/dynamic-import/instn-iee-err-circular-2_FIXTURE.js @@ -0,0 +1,4 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export { x } from './instn-iee-err-circular-1_FIXTURE.js'; diff --git a/test/language/module-code/dynamic-import/instn-iee-err-not-found-empty_FIXTURE.js b/test/language/module-code/dynamic-import/instn-iee-err-not-found-empty_FIXTURE.js new file mode 100644 index 0000000000..e46c626cf4 --- /dev/null +++ b/test/language/module-code/dynamic-import/instn-iee-err-not-found-empty_FIXTURE.js @@ -0,0 +1,4 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +; -- GitLab