Skip to content

Commit

Permalink
Dynamic Imports: initial cases, templates, non-generated tests and fi…
Browse files Browse the repository at this point in the history
…xtures
  • Loading branch information
rwaldron committed Jun 5, 2018
1 parent a8f7012 commit 80ab186
Show file tree
Hide file tree
Showing 52 changed files with 1,206 additions and 0 deletions.
4 changes: 4 additions & 0 deletions features.txt
Expand Up @@ -16,6 +16,10 @@ BigInt
class-fields-public
class-fields-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
Expand Down
32 changes: 32 additions & 0 deletions 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/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);
};
34 changes: 34 additions & 0 deletions 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/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);
34 changes: 34 additions & 0 deletions 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/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);
}
33 changes: 33 additions & 0 deletions 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/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 fn() {
import(/*{ params }*/).catch(error => {

/*{ body }*/

}).then($DONE, $DONE);
}
fn();
32 changes: 32 additions & 0 deletions 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/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);
}
32 changes: 32 additions & 0 deletions 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/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);
};
34 changes: 34 additions & 0 deletions 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/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);
};
30 changes: 30 additions & 0 deletions 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/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);
32 changes: 32 additions & 0 deletions 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);
};
34 changes: 34 additions & 0 deletions 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);
} while (!x);
34 changes: 34 additions & 0 deletions 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);
}

0 comments on commit 80ab186

Please sign in to comment.