Module semantics: declaration instantiation

Files whose name ends in `_.js` are not themselves valid Test262 tests
and should not be interpreted as such by test runners.

---

Because the tests in this patch concern declaration *instantiation*,
care has been taken to avoid asserting binding values following
evaluation. Because a given module's dependencies are evaluated prior to
the module itself, this is only observable in modules which import their
own bindings.

A separate patch dedicated to the evaluation of module code asserts the
behavior of bindings following evaluation.

---

For tests that concern the creation of a module namespace object, this
patch relies on the semantics of the `in` operator. The `in` operator
uses the [[HasProperty]] internal method and avoids testing unrelated
semantics concerning binding resolution. Those semantics should be
explicitly asserted with a separate set of tests dedicated to that
purpose.

---

One test case which is notably missing is error resulting from a cycle
due to an `import` declaration (under the current file naming scheme,
such a test might be named `instn-named-err-circular.js`). Due to the
recursive nature of ModuleDeclarationInstantiation, it is not
technically possible for a circular request to be found in step 12.c.i.
Cycles rely on at least 2 `export` declarations, and because these are
resolved *before* imports, any cycle would trigger failure prior to step
12.c.

---

One aspect of *module* resolution that makes ordering observable is the
fact that resolution can fail in two distinct ways (i.e. with a
SyntaxError or with a ReferenceError). This patch includes tests that
leverage this detail in order to assert that modules are resolved in the
correct sequence.

However, from the perspective of the ECMA-262 specification, the
ordering of *export* (e.g. binding) resolution is not observable. This
is due to restrictions on the grammar, where each export is independent.
When *export* resolution fails, it does so with instances of SyntaxError
alone, precluding the above strategy.

So while ModuleDeclarationInstantiation resolves the exports of the
module's dependencies in the following order:

1. "Indirect" exports, e.g.
   - `export { x } from './y.js';`
   - `export { x as z } from './y.js';`
   - `import { x } from './y.js'; export { x };`
2. "Star" imports
   - `import * as ns from './y.js';`
3. "Named" (my word) imports
   - `import x from './y.js';`
   - `import { x } from './y.js';`
   - `import { x as z } from './y.js';`

Intentional failures cannot be used to discern resolution ordering.
This commit is contained in:
Mike Pennisi 2016-03-29 11:50:15 -04:00
parent 3cb20b9df5
commit 4273ad1fa7
138 changed files with 3423 additions and 0 deletions

View File

@ -0,0 +1,47 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Imported binding reflects state of indirectly-exported `class` binding
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. If resolution is null or resolution is "ambiguous", throw a
SyntaxError exception.
iii. Call envRec.CreateImportBinding(in.[[LocalName]],
resolution.[[Module]], resolution.[[BindingName]]).
[...]
16. Let lexDeclarations be the LexicallyScopedDeclarations of code.
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i, If IsConstantDeclaration of d is true, then
[...]
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
iii. If d is a GeneratorDeclaration production or a
FunctionDeclaration production, then
[...]
8.1.1.5.5 CreateImportBinding
[...]
5. Create an immutable indirect binding in envRec for N that references M
and N2 as its target binding and record that the binding is initialized.
6. Return NormalCompletion(empty).
flags: [module]
---*/
assert.throws(ReferenceError, function() {
typeof B;
}, 'binding is created but not initialized');
import { B } from './instn-iee-bndng-cls_.js';
export class A {}

View File

@ -0,0 +1,18 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
export { A as B } from './instn-iee-bndng-cls.js';
// Taken together, the following two assertions demonstrate that there is no
// entry in the environment record for ImportName:
assert.throws(ReferenceError, function() {
A;
});
assert.sameValue(typeof A, 'undefined');
// Taken together, the following two assertions demonstrate that there is no
// entry in the environment record for ExportName:
assert.throws(ReferenceError, function() {
B;
});
assert.sameValue(typeof B, 'undefined');

View File

@ -0,0 +1,47 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Imported binding reflects state of indirectly-exported `const` binding
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. If resolution is null or resolution is "ambiguous", throw a
SyntaxError exception.
iii. Call envRec.CreateImportBinding(in.[[LocalName]],
resolution.[[Module]], resolution.[[BindingName]]).
[...]
16. Let lexDeclarations be the LexicallyScopedDeclarations of code.
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i, If IsConstantDeclaration of d is true, then
1. Perform ! envRec.CreateImmutableBinding(dn, true).
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
iii. If d is a GeneratorDeclaration production or a
FunctionDeclaration production, then
[...]
8.1.1.5.5 CreateImportBinding
[...]
5. Create an immutable indirect binding in envRec for N that references M
and N2 as its target binding and record that the binding is initialized.
6. Return NormalCompletion(empty).
flags: [module]
---*/
assert.throws(ReferenceError, function() {
typeof y;
}, 'binding is created but not initialized');
import { y } from './instn-iee-bndng-const_.js';
export const x = null;

View File

@ -0,0 +1,18 @@
// 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 as y } from './instn-iee-bndng-const.js';
// Taken together, the following two assertions demonstrate that there is no
// entry in the environment record for ImportName:
assert.throws(ReferenceError, function() {
x;
});
assert.sameValue(typeof x, 'undefined');
// Taken together, the following two assertions demonstrate that there is no
// entry in the environment record for ExportName:
assert.throws(ReferenceError, function() {
y;
});
assert.sameValue(typeof y, 'undefined');

View File

@ -0,0 +1,55 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Imported binding reflects state of indirectly-exported function binding
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. If resolution is null or resolution is "ambiguous", throw a
SyntaxError exception.
iii. Call envRec.CreateImportBinding(in.[[LocalName]],
resolution.[[Module]], resolution.[[BindingName]]).
[...]
16. Let lexDeclarations be the LexicallyScopedDeclarations of code.
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i, If IsConstantDeclaration of d is true, then
[...]
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
iii. If d is a GeneratorDeclaration production or a
FunctionDeclaration production, then
[...]
8.1.1.5.5 CreateImportBinding
[...]
5. Create an immutable indirect binding in envRec for N that references M
and N2 as its target binding and record that the binding is initialized.
6. Return NormalCompletion(empty).
flags: [module]
---*/
assert.sameValue(
f2(),
77,
'binding is initialized to function value prior to module evaluation'
);
assert.throws(TypeError, function() {
f2 = null;
}, 'binding rejects assignment');
assert.sameValue(f2(), 77, 'binding value is immutable');
import { f2 } from './instn-iee-bndng-fun_.js';
export function f() { return 77; }

View File

@ -0,0 +1,18 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
export { f as f2 } from './instn-iee-bndng-fun.js';
// Taken together, the following two assertions demonstrate that there is no
// entry in the environment record for ImportName:
assert.throws(ReferenceError, function() {
f;
});
assert.sameValue(typeof f, 'undefined');
// Taken together, the following two assertions demonstrate that there is no
// entry in the environment record for ExportName:
assert.throws(ReferenceError, function() {
f2;
});
assert.sameValue(typeof f2, 'undefined');

View File

@ -0,0 +1,56 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Imported binding reflects state of indirectly-exported generator function
binding
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. If resolution is null or resolution is "ambiguous", throw a
SyntaxError exception.
iii. Call envRec.CreateImportBinding(in.[[LocalName]],
resolution.[[Module]], resolution.[[BindingName]]).
[...]
16. Let lexDeclarations be the LexicallyScopedDeclarations of code.
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i, If IsConstantDeclaration of d is true, then
[...]
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
iii. If d is a GeneratorDeclaration production or a
FunctionDeclaration production, then
[...]
8.1.1.5.5 CreateImportBinding
[...]
5. Create an immutable indirect binding in envRec for N that references M
and N2 as its target binding and record that the binding is initialized.
6. Return NormalCompletion(empty).
flags: [module]
---*/
assert.sameValue(
g2().next().value,
455,
'binding is initialized to function value prior to module evaluation'
);
assert.throws(TypeError, function() {
g2 = null;
});
assert.sameValue(g2().next().value, 455, 'binding value is immutable');
import { g2 } from './instn-iee-bndng-gen_.js';
export function* g () { return 455; }

View File

@ -0,0 +1,18 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
export { g as g2 } from './instn-iee-bndng-gen.js';
// Taken together, the following two assertions demonstrate that there is no
// entry in the environment record for ImportName:
assert.throws(ReferenceError, function() {
g;
});
assert.sameValue(typeof g, 'undefined');
// Taken together, the following two assertions demonstrate that there is no
// entry in the environment record for ExportName:
assert.throws(ReferenceError, function() {
g2;
});
assert.sameValue(typeof g2, 'undefined');

View File

@ -0,0 +1,47 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Imported binding reflects state of indirectly-exported `let` binding
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. If resolution is null or resolution is "ambiguous", throw a
SyntaxError exception.
iii. Call envRec.CreateImportBinding(in.[[LocalName]],
resolution.[[Module]], resolution.[[BindingName]]).
[...]
16. Let lexDeclarations be the LexicallyScopedDeclarations of code.
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i, If IsConstantDeclaration of d is true, then
[...]
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
iii. If d is a GeneratorDeclaration production or a
FunctionDeclaration production, then
[...]
8.1.1.5.5 CreateImportBinding
[...]
5. Create an immutable indirect binding in envRec for N that references M
and N2 as its target binding and record that the binding is initialized.
6. Return NormalCompletion(empty).
flags: [module]
---*/
assert.throws(ReferenceError, function() {
typeof y;
}, 'binding is created but not initialized');
import { y } from './instn-iee-bndng-let_.js';
export let x;

View File

@ -0,0 +1,18 @@
// 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 as y } from './instn-iee-bndng-let.js';
// Taken together, the following two assertions demonstrate that there is no
// entry in the environment record for ImportName:
assert.throws(ReferenceError, function() {
x;
});
assert.sameValue(typeof x, 'undefined');
// Taken together, the following two assertions demonstrate that there is no
// entry in the environment record for ExportName:
assert.throws(ReferenceError, function() {
y;
});
assert.sameValue(typeof y, 'undefined');

View File

@ -0,0 +1,55 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Imported binding reflects state of indirectly-exported `var` binding
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. If resolution is null or resolution is "ambiguous", throw a
SyntaxError exception.
iii. Call envRec.CreateImportBinding(in.[[LocalName]],
resolution.[[Module]], resolution.[[BindingName]]).
[...]
16. Let lexDeclarations be the LexicallyScopedDeclarations of code.
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i, If IsConstantDeclaration of d is true, then
[...]
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
iii. If d is a GeneratorDeclaration production or a
FunctionDeclaration production, then
[...]
8.1.1.5.5 CreateImportBinding
[...]
5. Create an immutable indirect binding in envRec for N that references M
and N2 as its target binding and record that the binding is initialized.
6. Return NormalCompletion(empty).
flags: [module]
---*/
assert.sameValue(
y,
undefined,
'binding is initialized to `undefined` prior to module evaulation'
);
assert.throws(TypeError, function() {
y = null;
}, 'binding rejects assignment');
assert.sameValue(y, undefined, 'binding value is immutable');
import { y } from './instn-iee-bndng-var_.js';
export var x = 99;

View File

@ -0,0 +1,18 @@
// 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 as y } from './instn-iee-bndng-var.js';
// Taken together, the following two assertions demonstrate that there is no
// entry in the environment record for ImportName:
assert.throws(ReferenceError, function() {
x;
});
assert.sameValue(typeof x, 'undefined');
// Taken together, the following two assertions demonstrate that there is no
// entry in the environment record for ExportName:
assert.throws(ReferenceError, function() {
y;
});
assert.sameValue(typeof y, 'undefined');

View File

@ -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;

View File

@ -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;

View File

@ -0,0 +1,37 @@
// 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: SyntaxError
flags: [module]
---*/
export { x as y } from './instn-iee-err-ambiguous_.js';

View File

@ -0,0 +1,37 @@
// 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: SyntaxError
flags: [module]
---*/
export { x } from './instn-iee-err-ambiguous_.js';

View File

@ -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_.js';
export * from './instn-iee-err-ambiguous-2_.js';

View File

@ -0,0 +1,26 @@
// 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 - 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.
negative: SyntaxError
flags: [module]
---*/
export { x as y } from './instn-iee-err-circular_.js';

View File

@ -0,0 +1,26 @@
// 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 - 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.
negative: SyntaxError
flags: [module]
---*/
export { x } from './instn-iee-err-circular_.js';

View File

@ -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.js';

View File

@ -0,0 +1,25 @@
// 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 - default not found (excluding *)
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
[...]
6. If SameValue(exportName, "default") is true, then
a. Assert: A default export was not explicitly defined by this module.
b. Throw a SyntaxError exception.
c. NOTE A default export cannot be provided by an export *.
negative: SyntaxError
flags: [module]
---*/
export { default as x } from './instn-iee-err-dflt-thru-star-int_.js';

View File

@ -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.
var x;
export { x as default };

View File

@ -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 * from './instn-iee-err-dflt-thru-star-dflt_.js';

View File

@ -0,0 +1,25 @@
// 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 - default not found (excluding *)
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
[...]
6. If SameValue(exportName, "default") is true, then
a. Assert: A default export was not explicitly defined by this module.
b. Throw a SyntaxError exception.
c. NOTE A default export cannot be provided by an export *.
negative: SyntaxError
flags: [module]
---*/
export { default } from './instn-iee-err-dflt-thru-star-int_.js';

View File

@ -0,0 +1,25 @@
// 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 - 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.
negative: SyntaxError
flags: [module]
---*/
export { x as y } from './instn-iee-err-not-found-empty_.js';

View File

@ -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.
;

View File

@ -0,0 +1,25 @@
// 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 - 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.
negative: SyntaxError
flags: [module]
---*/
export { x } from './instn-iee-err-not-found-empty_.js';

View File

@ -0,0 +1,16 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
export { b as a } from './instn-iee-iee-cycle.js';
export { d as c } from './instn-iee-iee-cycle.js';
export { f as e } from './instn-iee-iee-cycle.js';
export { h as g } from './instn-iee-iee-cycle.js';
export { j as i } from './instn-iee-iee-cycle.js';
export { l as k } from './instn-iee-iee-cycle.js';
export { n as m } from './instn-iee-iee-cycle.js';
export { p as o } from './instn-iee-iee-cycle.js';
export { r as q } from './instn-iee-iee-cycle.js';
export { t as s } from './instn-iee-iee-cycle.js';
export { v as u } from './instn-iee-iee-cycle.js';
export { x as w } from './instn-iee-iee-cycle.js';
export { z as y } from './instn-iee-iee-cycle.js';

View File

@ -0,0 +1,49 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
There are no restrictions on the number of cycles during module traversal
during indirect export resolution, given unique export names.
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( exportName, resolveSet, exportStarSet )
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.
3. Append the Record {[[Module]]: module, [[ExportName]]: exportName} to resolveSet.
[...]
5. For each ExportEntry Record e in module.[[IndirectExportEntries]], do
a. If SameValue(exportName, e.[[ExportName]]) is true, then
i. Assert: module imports a specific binding for this export.
ii. Let importedModule be ? HostResolveImportedModule(module,
e.[[ModuleRequest]]).
iii. Let indirectResolution be ?
importedModule.ResolveExport(e.[[ImportName]], resolveSet,
exportStarSet).
iv. If indirectResolution is not null, return indirectResolution.
flags: [module]
---*/
export { a } from './instn-iee-iee-cycle-2_.js';
export { c as b } from './instn-iee-iee-cycle-2_.js';
export { e as d } from './instn-iee-iee-cycle-2_.js';
export { g as f } from './instn-iee-iee-cycle-2_.js';
export { i as h } from './instn-iee-iee-cycle-2_.js';
export { k as j } from './instn-iee-iee-cycle-2_.js';
export { m as l } from './instn-iee-iee-cycle-2_.js';
export { o as n } from './instn-iee-iee-cycle-2_.js';
export { q as p } from './instn-iee-iee-cycle-2_.js';
export { s as r } from './instn-iee-iee-cycle-2_.js';
export { u as t } from './instn-iee-iee-cycle-2_.js';
export { w as v } from './instn-iee-iee-cycle-2_.js';
export { y as x } from './instn-iee-iee-cycle-2_.js';
export var z;

View File

@ -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 * from './instn-iee-star-cycle-indirect-x_.js';

View File

@ -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.
// This module should be visited exactly one time during resolution of the "x"
// binding.
export { y as x } from './instn-iee-star-cycle-2_.js';
export var y = 45;

View File

@ -0,0 +1,25 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Modules are visited no more than one time when resolving bindings through
"star" exports.
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( exportName, resolveSet, exportStarSet )
[...]
7. If exportStarSet contains module, return null.
8. Append module to exportStarSet.
[...]
negative: SyntaxError
flags: [module]
---*/
export { x } from './instn-iee-star-cycle-2_.js';

View File

@ -0,0 +1,21 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
ExportsList in ExportDeclaration may include a trailing comma
esid: sec-moduledeclarationinstantiation
info: |
[...]
9. For each ExportEntry Record e in module.[[IndirectExportEntries]], do
a. Let resolution be ? module.ResolveExport(e.[[ExportName]], « », « »).
[...]
flags: [module]
---*/
export { a , } from './instn-iee-trlng-comma_.js';
export { a as b , } from './instn-iee-trlng-comma_.js';
import { a, b } from './instn-iee-trlng-comma.js';
assert.sameValue(a, 333, 'comma following named export');
assert.sameValue(b, 333, 'comma following re-named export');

View File

@ -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 a = 333;

View File

@ -0,0 +1,44 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Mutable bindings are created in the lexical environment record prior to
execution for class declarations
esid: sec-moduledeclarationinstantiation
info: |
[...]
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i. If IsConstantDeclaration of d is true, then
[...]
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
[...]
includes: [fnGlobalObject.js]
flags: [module]
---*/
var global = fnGlobalObject();
assert.throws(ReferenceError, function() {
typeof test262;
}, 'Binding is created but not initialized.');
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'), undefined
);
class test262 {}
assert.sameValue(typeof test262, 'function');
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'), undefined
);
test262 = null;
assert.sameValue(test262, null, 'binding is mutable');
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'),
undefined,
'global binding is not effected by modification'
);

View File

@ -0,0 +1,44 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Mutable bindings are created in the lexical environment record prior to
execution for `const` declarations
esid: sec-moduledeclarationinstantiation
info: |
[...]
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i. If IsConstantDeclaration of d is true, then
1. Perform ! envRec.CreateImmutableBinding(dn, true).
[...]
includes: [fnGlobalObject.js]
flags: [module]
---*/
var global = fnGlobalObject();
assert.throws(ReferenceError, function() {
typeof test262;
}, 'Binding is created but not initialized.');
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'), undefined
);
const test262 = 23;
assert.sameValue(test262, 23);
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'), undefined
);
assert.throws(TypeError, function() {
test262 = null;
});
assert.sameValue(test262, 23, 'binding is not mutable');
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'),
undefined,
'global binding is not effected by attempts to modify'
);

View File

@ -0,0 +1,30 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Binding is created and initialized to `undefined` for exported `class`
declarations
esid: sec-moduledeclarationinstantiation
info: |
[...]
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i. If IsConstantDeclaration of d is true, then
[...]
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
[...]
includes: [fnGlobalObject.js]
flags: [module]
---*/
var global = fnGlobalObject();
assert.throws(ReferenceError, function() {
typeof test262;
}, 'Binding is created but not initialized.');
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'), undefined
);
export class test262 {}

View File

@ -0,0 +1,29 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Binding is created but not initialized for exported `const` statements
esid: sec-moduledeclarationinstantiation
info: |
[...]
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i. If IsConstantDeclaration of d is true, then
[...]
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
[...]
includes: [fnGlobalObject.js]
flags: [module]
---*/
var global = fnGlobalObject();
assert.throws(ReferenceError, function() {
typeof test262;
}, 'Binding is created but not initialized.');
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'), undefined
);
export const test262 = 23;

View File

@ -0,0 +1,32 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Binding is created and initialized to `undefined` for exported function
declarations
esid: sec-moduledeclarationinstantiation
info: |
[...]
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i. If IsConstantDeclaration of d is true, then
[...]
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
[...]
includes: [fnGlobalObject.js]
flags: [module]
---*/
var global = fnGlobalObject();
assert.sameValue(test262(), 23, 'initialized value');
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'), undefined
);
test262 = null;
assert.sameValue(test262, null, 'binding is mutable');
export function test262() { return 23; }

View File

@ -0,0 +1,32 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Binding is created and initialized to `undefined` for exported generator
function declarations
esid: sec-moduledeclarationinstantiation
info: |
[...]
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i. If IsConstantDeclaration of d is true, then
[...]
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
[...]
includes: [fnGlobalObject.js]
flags: [module]
---*/
var global = fnGlobalObject();
assert.sameValue(test262().next().value, 23, 'initialized value');
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'), undefined
);
test262 = null;
assert.sameValue(test262, null, 'binding is mutable');
export function* test262() { return 23; }

View File

@ -0,0 +1,29 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Binding is created but not initialized for exported `let` statements
esid: sec-moduledeclarationinstantiation
info: |
[...]
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i. If IsConstantDeclaration of d is true, then
[...]
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
[...]
includes: [fnGlobalObject.js]
flags: [module]
---*/
var global = fnGlobalObject();
assert.throws(ReferenceError, function() {
typeof test262;
}, 'Binding is created but not initialized.');
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'), undefined
);
export let test262 = 23;

View File

@ -0,0 +1,32 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Binding is created and initialized to `undefined` for exported `var`
declarations
esid: sec-moduledeclarationinstantiation
info: |
[...]
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i. If IsConstantDeclaration of d is true, then
[...]
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
[...]
includes: [fnGlobalObject.js]
flags: [module]
---*/
var global = fnGlobalObject();
assert.sameValue(test262, undefined, 'initialized value');
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'), undefined
);
test262 = null;
assert.sameValue(test262, null, 'binding is mutable');
export var test262 = 23;

View File

@ -0,0 +1,23 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Only one attempt is made to create a binding for any number of variable
declarations within `for` statements
esid: sec-moduledeclarationinstantiation
info: |
[...]
13. Let varDeclarations be the VarScopedDeclarations of code.
14. Let declaredVarNames be a new empty List.
15. For each element d in varDeclarations do
a. For each element dn of the BoundNames of d do
i. If dn is not an element of declaredVarNames, then
1. Perform ! envRec.CreateMutableBinding(dn, false).
[...]
3. Append dn to declaredVarNames.
[...]
flags: [module]
---*/
for (var test262; false; ) {}
for (var test262; false; ) {}

View File

@ -0,0 +1,36 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Mutable bindings are initialized in the lexical environment record prior to
execution for variable declarations within `for` statements
esid: sec-moduledeclarationinstantiation
info: |
[...]
13. Let varDeclarations be the VarScopedDeclarations of code.
14. Let declaredVarNames be a new empty List.
15. For each element d in varDeclarations do
a. For each element dn of the BoundNames of d do
i. If dn is not an element of declaredVarNames, then
1. Perform ! envRec.CreateMutableBinding(dn, false).
2. Call envRec.InitializeBinding(dn, undefined).
[...]
includes: [fnGlobalObject.js]
flags: [module]
---*/
var global = fnGlobalObject();
assert.sameValue(test262, undefined, 'value is initialized to `undefined`');
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'), undefined
);
for (var test262 = null; false; ) {}
assert.sameValue(test262, null, 'binding is mutable');
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'),
undefined,
'global binding is not effected by evaluation of declaration'
);

View File

@ -0,0 +1,49 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Mutable bindings are initialized in the lexical environment record prior to
execution for function declarations
esid: sec-moduledeclarationinstantiation
info: |
[...]
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i. If IsConstantDeclaration of d is true, then
[...]
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
iii. If d is a GeneratorDeclaration production or a
FunctionDeclaration production, then
1. Let fo be the result of performing InstantiateFunctionObject
for d with argument env.
2. Call envRec.InitializeBinding(dn, fo).
[...]
includes: [fnGlobalObject.js]
flags: [module]
---*/
var global = fnGlobalObject();
assert.sameValue(typeof test262, 'function', 'function value is hoisted');
assert.sameValue(test262(), 'test262', 'hoisted function value is correct');
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'), undefined
);
test262 = null;
assert.sameValue(test262, null, 'binding is mutable');
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'), undefined
);
function test262() { return 'test262'; }
assert.sameValue(
test262, null, 'binding is not effected by evaluation of declaration'
);
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'),
undefined,
'global binding is not effected by evaluation of declaration'
);

View File

@ -0,0 +1,50 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Mutable bindings are initialized in the lexical environment record prior to
execution for generator function declarations
esid: sec-moduledeclarationinstantiation
info: |
[...]
15. For each element d in varDeclarations do
a. For each element dn of the BoundNames of d do
i. If dn is not an element of declaredVarNames, then
1. Perform ! envRec.CreateMutableBinding(dn, false).
2. Call envRec.InitializeBinding(dn, undefined).
3. Append dn to declaredVarNames.
[...]
includes: [fnGlobalObject.js]
flags: [module]
---*/
var global = fnGlobalObject();
assert.sameValue(
typeof test262, 'function', 'generator function value is hoisted'
);
assert.sameValue(
test262().next().value,
'test262',
'hoisted generator function value is correct'
);
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'), undefined
);
test262 = null;
assert.sameValue(test262, null, 'binding is mutable');
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'), undefined
);
function* test262() { return 'test262'; }
assert.sameValue(
test262, null, 'binding is not effected by evaluation of declaration'
);
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'),
undefined,
'global binding is not effected by evaluation of declaration'
);

View File

@ -0,0 +1,44 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Mutable bindings are created in the lexical environment record prior to
execution for `let` declarations
esid: sec-moduledeclarationinstantiation
info: |
[...]
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i. If IsConstantDeclaration of d is true, then
[...]
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
[...]
includes: [fnGlobalObject.js]
flags: [module]
---*/
var global = fnGlobalObject();
assert.throws(ReferenceError, function() {
typeof test262;
}, 'Binding is created but not initialized.');
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'), undefined
);
let test262;
assert.sameValue(test262, undefined);
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'), undefined
);
test262 = null;
assert.sameValue(test262, null, 'binding is mutable');
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'),
undefined,
'global binding is not effected by modification'
);

View File

@ -0,0 +1,23 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Only one attempt is made to create a binding for any number of variable
declarations
esid: sec-moduledeclarationinstantiation
info: |
[...]
13. Let varDeclarations be the VarScopedDeclarations of code.
14. Let declaredVarNames be a new empty List.
15. For each element d in varDeclarations do
a. For each element dn of the BoundNames of d do
i. If dn is not an element of declaredVarNames, then
1. Perform ! envRec.CreateMutableBinding(dn, false).
[...]
3. Append dn to declaredVarNames.
[...]
flags: [module]
---*/
var test262;
var test262;

View File

@ -0,0 +1,37 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Mutable bindings are initialized in the lexical environment record prior to
execution for variable declarations
esid: sec-moduledeclarationinstantiation
info: |
[...]
13. Let varDeclarations be the VarScopedDeclarations of code.
14. Let declaredVarNames be a new empty List.
15. For each element d in varDeclarations do
a. For each element dn of the BoundNames of d do
i. If dn is not an element of declaredVarNames, then
1. Perform ! envRec.CreateMutableBinding(dn, false).
2. Call envRec.InitializeBinding(dn, undefined).
3. Append dn to declaredVarNames.
[...]
includes: [fnGlobalObject.js]
flags: [module]
---*/
var global = fnGlobalObject();
assert.sameValue(test262, undefined, 'value is initialized to `undefined`');
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'), undefined
);
var test262 = null;
assert.sameValue(test262, null, 'binding is mutable');
assert.sameValue(
Object.getOwnPropertyDescriptor(global, 'test262'),
undefined,
'global binding is not effected by evaluation of declaration'
);

View File

@ -0,0 +1,46 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Imported binding reflects state of exported `class` binding
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. If resolution is null or resolution is "ambiguous", throw a
SyntaxError exception.
iii. Call envRec.CreateImportBinding(in.[[LocalName]],
resolution.[[Module]], resolution.[[BindingName]]).
[...]
16. Let lexDeclarations be the LexicallyScopedDeclarations of code.
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i, If IsConstantDeclaration of d is true, then
[...]
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
iii. If d is a GeneratorDeclaration production or a
FunctionDeclaration production, then
[...]
8.1.1.5.5 CreateImportBinding
[...]
5. Create an immutable indirect binding in envRec for N that references M
and N2 as its target binding and record that the binding is initialized.
6. Return NormalCompletion(empty).
flags: [module]
---*/
assert.throws(ReferenceError, function() {
typeof D;
}, 'binding is created but not initialized');
import { C as D } from './instn-named-bndng-cls.js';
export class C {}

View File

@ -0,0 +1,46 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Imported binding reflects state of exported `const` binding
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. If resolution is null or resolution is "ambiguous", throw a
SyntaxError exception.
iii. Call envRec.CreateImportBinding(in.[[LocalName]],
resolution.[[Module]], resolution.[[BindingName]]).
[...]
16. Let lexDeclarations be the LexicallyScopedDeclarations of code.
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i, If IsConstantDeclaration of d is true, then
1. Perform ! envRec.CreateImmutableBinding(dn, true).
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
iii. If d is a GeneratorDeclaration production or a
FunctionDeclaration production, then
[...]
8.1.1.5.5 CreateImportBinding
[...]
5. Create an immutable indirect binding in envRec for N that references M
and N2 as its target binding and record that the binding is initialized.
6. Return NormalCompletion(empty).
flags: [module]
---*/
assert.throws(ReferenceError, function() {
typeof y;
}, 'binding is created but not initialized');
import { x as y } from './instn-named-bndng-const.js';
export const x = 23;

View File

@ -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: >
Imported binding reflects state of exported default binding ("anonymous"
class declaration)
esid: sec-moduledeclarationinstantiation
info: |
[...]
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i. If IsConstantDeclaration of d is true, then
[...]
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
iii. If d is a GeneratorDeclaration production or a
FunctionDeclaration production, then
1. Let fo be the result of performing InstantiateFunctionObject
for d with argument env.
2. Call envRec.InitializeBinding(dn, fo).
[...]
14.5 Class Definitions
Syntax
ClassDeclaration[Yield, Default]:
class BindingIdentifier[?Yield] ClassTail[?Yield]
[+Default] class ClassTail[?Yield]
flags: [module]
---*/
assert.throws(ReferenceError, function() {
typeof C;
}, 'Binding is created but not initialized.');
export default class {};
import C from './instn-named-bndng-dflt-cls.js';

View File

@ -0,0 +1,37 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description:
Imported binding reflects state of exported default binding (expressions)
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. If resolution is null or resolution is "ambiguous", throw a
SyntaxError exception.
iii. Call envRec.CreateImportBinding(in.[[LocalName]],
resolution.[[Module]], resolution.[[BindingName]]).
[...]
8.1.1.5.5 CreateImportBinding
[...]
5. Create an immutable indirect binding in envRec for N that references M
and N2 as its target binding and record that the binding is initialized.
6. Return NormalCompletion(empty).
flags: [module]
---*/
assert.throws(ReferenceError, function() {
typeof dflt;
}, 'binding is created but not initialized');
import dflt from './instn-named-bndng-dflt-expr.js';
export default (function() {});

View File

@ -0,0 +1,50 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Imported binding reflects state of exported default binding ("anonymous"
function declaration)
esid: sec-moduledeclarationinstantiation
info: |
[...]
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i. If IsConstantDeclaration of d is true, then
[...]
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
iii. If d is a GeneratorDeclaration production or a
FunctionDeclaration production, then
1. Let fo be the result of performing InstantiateFunctionObject
for d with argument env.
2. Call envRec.InitializeBinding(dn, fo).
[...]
14.1.20 Runtime Semantics: InstantiateFunctionObject
FunctionDeclaration : function ( FormalParameters ) { FunctionBody }
1. If the function code for FunctionDeclaration is strict mode code, let
strict be true. Otherwise let strict be false.
2. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, scope,
strict).
3. Perform MakeConstructor(F).
4. Perform SetFunctionName(F, "default").
5. Return F.
14.1 Function Definitions
Syntax
FunctionDeclaration[Yield, Default] :
function BindingIdentifier[?Yield] ( FormalParameters ) { FunctionBody }
[+Default] function ( FormalParameters ) { FunctionBody }
flags: [module]
---*/
assert.sameValue(f(), 23, 'function value is hoisted');
assert.sameValue(f.name, 'default', 'correct name is assigned');
import f from './instn-named-bndng-dflt-fun-anon.js';
export default function() { return 23; };

View File

@ -0,0 +1,50 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Imported binding reflects state of exported default binding ("named"
function declaration)
esid: sec-moduledeclarationinstantiation
info: |
[...]
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i. If IsConstantDeclaration of d is true, then
[...]
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
iii. If d is a GeneratorDeclaration production or a
FunctionDeclaration production, then
1. Let fo be the result of performing InstantiateFunctionObject
for d with argument env.
2. Call envRec.InitializeBinding(dn, fo).
[...]
14.1.20 Runtime Semantics: InstantiateFunctionObject
FunctionDeclaration : function ( FormalParameters ) { FunctionBody }
1. If the function code for FunctionDeclaration is strict mode code, let
strict be true. Otherwise let strict be false.
2. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, scope,
strict).
3. Perform MakeConstructor(F).
4. Perform SetFunctionName(F, "default").
5. Return F.
14.1 Function Definitions
Syntax
FunctionDeclaration[Yield, Default] :
function BindingIdentifier[?Yield] ( FormalParameters ) { FunctionBody }
[+Default] function ( FormalParameters ) { FunctionBody }
flags: [module]
---*/
assert.sameValue(f(), 23, 'function value is hoisted');
assert.sameValue(f.name, 'fName', 'correct name is assigned');
import f from './instn-named-bndng-dflt-fun-named.js';
export default function fName() { return 23; };

View File

@ -0,0 +1,52 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Imported binding reflects state of exported default binding ("anonymous"
generator function declaration)
esid: sec-moduledeclarationinstantiation
info: |
[...]
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i. If IsConstantDeclaration of d is true, then
[...]
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
iii. If d is a GeneratorDeclaration production or a
FunctionDeclaration production, then
1. Let fo be the result of performing InstantiateFunctionObject
for d with argument env.
2. Call envRec.InitializeBinding(dn, fo).
[...]
14.4.12 Runtime Semantics: InstantiateFunctionObject
GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody }
1. If the function code for GeneratorDeclaration is strict mode code, let
strict be true. Otherwise let strict be false.
2. Let F be GeneratorFunctionCreate(Normal, FormalParameters,
GeneratorBody, scope, strict).
3. Let prototype be ObjectCreate(%GeneratorPrototype%).
4. Perform DefinePropertyOrThrow(F, "prototype",
PropertyDescriptor{[[Value]]: prototype, [[Writable]]: true,
[[Enumerable]]: false, [[Configurable]]: false}).
5. Perform SetFunctionName(F, "default").
6. Return F.
14.4 Generator Function Definitions
Syntax
GeneratorDeclaration[Yield, Default] :
function * BindingIdentifier[?Yield] ( FormalParameters[Yield] ) { GeneratorBody }
[+Default] function * ( FormalParameters[Yield] ) { GeneratorBody }
flags: [module]
---*/
assert.sameValue(g().next().value, 23, 'generator function value is hoisted');
assert.sameValue(g.name, 'default', 'correct name is assigned');
import g from './instn-named-bndng-dflt-gen-anon.js';
export default function* () { return 23; };

View File

@ -0,0 +1,52 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Imported binding reflects state of exported default binding ("named"
generator function declaration)
esid: sec-moduledeclarationinstantiation
info: |
[...]
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i. If IsConstantDeclaration of d is true, then
[...]
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
iii. If d is a GeneratorDeclaration production or a
FunctionDeclaration production, then
1. Let fo be the result of performing InstantiateFunctionObject
for d with argument env.
2. Call envRec.InitializeBinding(dn, fo).
[...]
14.4.12 Runtime Semantics: InstantiateFunctionObject
GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody }
1. If the function code for GeneratorDeclaration is strict mode code, let
strict be true. Otherwise let strict be false.
2. Let F be GeneratorFunctionCreate(Normal, FormalParameters,
GeneratorBody, scope, strict).
3. Let prototype be ObjectCreate(%GeneratorPrototype%).
4. Perform DefinePropertyOrThrow(F, "prototype",
PropertyDescriptor{[[Value]]: prototype, [[Writable]]: true,
[[Enumerable]]: false, [[Configurable]]: false}).
5. Perform SetFunctionName(F, "default").
6. Return F.
14.4 Generator Function Definitions
Syntax
GeneratorDeclaration[Yield, Default] :
function * BindingIdentifier[?Yield] ( FormalParameters[Yield] ) { GeneratorBody }
[+Default] function * ( FormalParameters[Yield] ) { GeneratorBody }
flags: [module]
---*/
assert.sameValue(g().next().value, 23, 'generator function value is hoisted');
assert.sameValue(g.name, 'gName', 'correct name is assigned');
import g from './instn-named-bndng-dflt-gen-named.js';
export default function* gName() { return 23; };

View File

@ -0,0 +1,27 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
An ImportClause may contain both an ImportedDefaultBinding and NamedImports
esid: sec-imports
info: |
Syntax
ImportClause:
ImportedDefaultBinding
NameSpaceImport
NamedImports
ImportedDefaultBinding , NameSpaceImport
ImportedDefaultBinding , NamedImports
flags: [module]
---*/
assert.throws(ReferenceError, function() {
typeof x;
});
assert.sameValue(y, undefined);
export default 3;
export var attr;
import x, { attr as y } from './instn-named-bndng-dflt-named.js';

View File

@ -0,0 +1,28 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
An ImportClause may contain both an ImportedDefaultBinding and a
NameSpaceImport
esid: sec-imports
info: |
Syntax
ImportClause:
ImportedDefaultBinding
NameSpaceImport
NamedImports
ImportedDefaultBinding , NameSpaceImport
ImportedDefaultBinding , NamedImports
flags: [module]
---*/
assert.throws(ReferenceError, function() {
typeof x;
});
assert('attr' in ns);
export default 3;
export var attr;
import x, * as ns from './instn-named-bndng-dflt-star.js';

View File

@ -0,0 +1,57 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Imported binding reflects state of exported function binding
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. If resolution is null or resolution is "ambiguous", throw a
SyntaxError exception.
iii. Call envRec.CreateImportBinding(in.[[LocalName]],
resolution.[[Module]], resolution.[[BindingName]]).
[...]
16. Let lexDeclarations be the LexicallyScopedDeclarations of code.
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i, If IsConstantDeclaration of d is true, then
1. Perform ! envRec.CreateImmutableBinding(dn, true).
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
iii. If d is a GeneratorDeclaration production or a
FunctionDeclaration production, then
1. Let fo be the result of performing InstantiateFunctionObject
for d with argument env.
2. Call envRec.InitializeBinding(dn, fo).
[...]
8.1.1.5.5 CreateImportBinding
[...]
5. Create an immutable indirect binding in envRec for N that references M
and N2 as its target binding and record that the binding is initialized.
6. Return NormalCompletion(empty).
flags: [module]
---*/
assert.sameValue(
f2(),
23,
'binding is initialized to function value prior to module evaluation'
);
assert.throws(TypeError, function() {
f2 = null;
}, 'binding rejects assignment');
assert.sameValue(f2(), 23, 'binding value is immutable');
import { f as f2 } from './instn-named-bndng-fun.js';
export function f() { return 23; }

View File

@ -0,0 +1,58 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Imported binding reflects state of exported generator function binding
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. If resolution is null or resolution is "ambiguous", throw a
SyntaxError exception.
iii. Call envRec.CreateImportBinding(in.[[LocalName]],
resolution.[[Module]], resolution.[[BindingName]]).
[...]
16. Let lexDeclarations be the LexicallyScopedDeclarations of code.
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i, If IsConstantDeclaration of d is true, then
1. Perform ! envRec.CreateImmutableBinding(dn, true).
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
iii. If d is a GeneratorDeclaration production or a
FunctionDeclaration production, then
1. Let fo be the result of performing InstantiateFunctionObject
for d with argument env.
2. Call envRec.InitializeBinding(dn, fo).
[...]
8.1.1.5.5 CreateImportBinding
[...]
5. Create an immutable indirect binding in envRec for N that references M
and N2 as its target binding and record that the binding is initialized.
6. Return NormalCompletion(empty).
flags: [module]
---*/
assert.sameValue(
g2().next().value,
23,
'binding is initialized to function value prior to module evaluation'
);
assert.throws(TypeError, function() {
g2 = null;
}, 'binding rejects assignment');
assert.sameValue(g2().next().value, 23, 'binding value is immutable');
import { g as g2 } from './instn-named-bndng-gen.js';
export function* g() { return 23; }

View File

@ -0,0 +1,46 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Imported binding reflects state of exported `const` binding
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. If resolution is null or resolution is "ambiguous", throw a
SyntaxError exception.
iii. Call envRec.CreateImportBinding(in.[[LocalName]],
resolution.[[Module]], resolution.[[BindingName]]).
[...]
16. Let lexDeclarations be the LexicallyScopedDeclarations of code.
17. For each element d in lexDeclarations do
a. For each element dn of the BoundNames of d do
i, If IsConstantDeclaration of d is true, then
1. Perform ! envRec.CreateImmutableBinding(dn, true).
ii. Else,
1. Perform ! envRec.CreateMutableBinding(dn, false).
iii. If d is a GeneratorDeclaration production or a
FunctionDeclaration production, then
[...]
8.1.1.5.5 CreateImportBinding
[...]
5. Create an immutable indirect binding in envRec for N that references M
and N2 as its target binding and record that the binding is initialized.
6. Return NormalCompletion(empty).
flags: [module]
---*/
assert.throws(ReferenceError, function() {
typeof y;
}, 'binding is created but not initialized');
import { x as y } from './instn-named-bndng-let.js';
export let x = 23;

View File

@ -0,0 +1,54 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Imported binding reflects state of exported `var` binding when ImportsList
has a trailing comma
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. If resolution is null or resolution is "ambiguous", throw a
SyntaxError exception.
iii. Call envRec.CreateImportBinding(in.[[LocalName]],
resolution.[[Module]], resolution.[[BindingName]]).
[...]
14. Let declaredVarNames be a new empty List.
15. For each element d in varDeclarations do
a. For each element dn of the BoundNames of d do
i. If dn is not an element of declaredVarNames, then
1. Perform ! envRec.CreateMutableBinding(dn, false).
2. Call envRec.InitializeBinding(dn, undefined).
3. Append dn to declaredVarNames.
[...]
8.1.1.5.5 CreateImportBinding
[...]
5. Create an immutable indirect binding in envRec for N that references M
and N2 as its target binding and record that the binding is initialized.
6. Return NormalCompletion(empty).
flags: [module]
---*/
assert.sameValue(
y,
undefined,
'binding is initialized to `undefined` prior to module evaulation'
);
assert.throws(TypeError, function() {
y = null;
}, 'binding rejects assignment');
assert.sameValue(y, undefined, 'binding value is immutable');
import { x as y , } from './instn-named-bndng-trlng-comma.js';
export var x = 23;

View File

@ -0,0 +1,52 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Imported binding reflects state of exported `var` binding
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. If resolution is null or resolution is "ambiguous", throw a
SyntaxError exception.
iii. Call envRec.CreateImportBinding(in.[[LocalName]],
resolution.[[Module]], resolution.[[BindingName]]).
[...]
14. Let declaredVarNames be a new empty List.
15. For each element d in varDeclarations do
a. For each element dn of the BoundNames of d do
i. If dn is not an element of declaredVarNames, then
1. Perform ! envRec.CreateMutableBinding(dn, false).
2. Call envRec.InitializeBinding(dn, undefined).
3. Append dn to declaredVarNames.
[...]
8.1.1.5.5 CreateImportBinding
[...]
5. Create an immutable indirect binding in envRec for N that references M
and N2 as its target binding and record that the binding is initialized.
6. Return NormalCompletion(empty).
flags: [module]
---*/
assert.sameValue(
y,
undefined,
'binding is initialized to `undefined` prior to module evaulation'
);
assert.throws(TypeError, function() {
y = null;
}, 'binding rejects assignment');
assert.sameValue(y, undefined, 'binding value is immutable');
import { x as y } from './instn-named-bndng-var.js';
export var x = 23;

View File

@ -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;

View File

@ -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;

View File

@ -0,0 +1,42 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Named import binding - resolution failure (ambiguous name)
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. 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: SyntaxError
flags: [module]
---*/
import { x as y } from './instn-named-err-ambiguous_.js';

View File

@ -0,0 +1,42 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Named import binding - resolution failure (ambiguous name)
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. 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: SyntaxError
flags: [module]
---*/
import { x } from './instn-named-err-ambiguous_.js';

View File

@ -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-named-err-ambiguous-1_.js';
export * from './instn-named-err-ambiguous-2_.js';

View File

@ -0,0 +1,30 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Named import binding - default not found (excluding *)
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. If resolution is null or resolution is "ambiguous", throw a
SyntaxError exception.
15.2.1.16.3 ResolveExport
[...]
6. If SameValue(exportName, "default") is true, then
a. Assert: A default export was not explicitly defined by this module.
b. Throw a SyntaxError exception.
c. NOTE A default export cannot be provided by an export *.
negative: SyntaxError
flags: [module]
---*/
import { default as x } from './instn-named-err-dflt-thru-star-int_.js';

View File

@ -0,0 +1,30 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Named import binding - default not found (excluding *)
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. If resolution is null or resolution is "ambiguous", throw a
SyntaxError exception.
15.2.1.16.3 ResolveExport
[...]
6. If SameValue(exportName, "default") is true, then
a. Assert: A default export was not explicitly defined by this module.
b. Throw a SyntaxError exception.
c. NOTE A default export cannot be provided by an export *.
negative: SyntaxError
flags: [module]
---*/
import x from './instn-named-err-dflt-thru-star-int_.js';

View File

@ -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.
var x;
export { x as default };

View File

@ -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 * from './instn-named-err-dflt-thru-star-dflt_.js';

View File

@ -0,0 +1,30 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Named import binding - resolution failure (not found)
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. 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.
negative: SyntaxError
flags: [module]
---*/
import { x as y } from './instn-named-err-not-found-empty_.js';

View File

@ -0,0 +1,30 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Named import binding - resolution failure (not found)
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. 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.
negative: SyntaxError
flags: [module]
---*/
import x from './instn-named-err-not-found-empty_.js';

View File

@ -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.
;

View File

@ -0,0 +1,30 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Named import binding - resolution failure (not found)
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. 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.
negative: SyntaxError
flags: [module]
---*/
import { x } from './instn-named-err-not-found-empty_.js';

View File

@ -0,0 +1,53 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
The first identifier in an ImportSpecifier containing `as` may be any valid
IdentifierName
esid: sec-imports
info: |
ImportSpecifier:
ImportedBinding
IdentifierName as ImportedBinding
flags: [module]
---*/
var _if = 1;
var _import = 2;
var _export = 3;
var _await = 4;
var _arguments = 5;
var _eval = 6;
var _default = 7;
var _as = 8;
export {
_if as if,
_import as import,
_export as export,
_await as await,
_arguments as arguments,
_eval as eval,
_default as default,
_as as as
};
import {
if as if_,
import as import_,
export as export_,
await as await_,
arguments as arguments_,
eval as eval_,
default as default_,
as as as
} from './instn-named-id-name.js';
assert.sameValue(if_, 1);
assert.sameValue(import_, 2);
assert.sameValue(export_, 3);
assert.sameValue(await_, 4);
assert.sameValue(arguments_, 5);
assert.sameValue(eval_, 6);
assert.sameValue(default_, 7);
assert.sameValue(as, 8);

View File

@ -0,0 +1,16 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
export { b as a } from './instn-named-iee-cycle.js';
export { d as c } from './instn-named-iee-cycle.js';
export { f as e } from './instn-named-iee-cycle.js';
export { h as g } from './instn-named-iee-cycle.js';
export { j as i } from './instn-named-iee-cycle.js';
export { l as k } from './instn-named-iee-cycle.js';
export { n as m } from './instn-named-iee-cycle.js';
export { p as o } from './instn-named-iee-cycle.js';
export { r as q } from './instn-named-iee-cycle.js';
export { t as s } from './instn-named-iee-cycle.js';
export { v as u } from './instn-named-iee-cycle.js';
export { x as w } from './instn-named-iee-cycle.js';
export { z as y } from './instn-named-iee-cycle.js';

View File

@ -0,0 +1,60 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
There are no restrictions on the number of cycles during module traversal
during indirect export resolution, given unique export names.
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. If resolution is null or resolution is "ambiguous", throw a
SyntaxError exception.
iii. Call envRec.CreateImportBinding(in.[[LocalName]],
resolution.[[Module]], resolution.[[BindingName]]).
[...]
15.2.1.16.3 ResolveExport( exportName, resolveSet, exportStarSet )
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.
3. Append the Record {[[Module]]: module, [[ExportName]]: exportName} to resolveSet.
[...]
5. For each ExportEntry Record e in module.[[IndirectExportEntries]], do
a. If SameValue(exportName, e.[[ExportName]]) is true, then
i. Assert: module imports a specific binding for this export.
ii. Let importedModule be ? HostResolveImportedModule(module,
e.[[ModuleRequest]]).
iii. Let indirectResolution be ?
importedModule.ResolveExport(e.[[ImportName]], resolveSet,
exportStarSet).
iv. If indirectResolution is not null, return indirectResolution.
flags: [module]
---*/
import { a } from './instn-named-iee-cycle-2_.js';
export { c as b } from './instn-named-iee-cycle-2_.js';
export { e as d } from './instn-named-iee-cycle-2_.js';
export { g as f } from './instn-named-iee-cycle-2_.js';
export { i as h } from './instn-named-iee-cycle-2_.js';
export { k as j } from './instn-named-iee-cycle-2_.js';
export { m as l } from './instn-named-iee-cycle-2_.js';
export { o as n } from './instn-named-iee-cycle-2_.js';
export { q as p } from './instn-named-iee-cycle-2_.js';
export { s as r } from './instn-named-iee-cycle-2_.js';
export { u as t } from './instn-named-iee-cycle-2_.js';
export { w as v } from './instn-named-iee-cycle-2_.js';
export { y as x } from './instn-named-iee-cycle-2_.js';
export var z = 23;
assert.sameValue(a, 23);

View File

@ -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 * from './instn-named-star-cycle-indirect-x_.js';

View File

@ -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.
// This module should be visited exactly one time during resolution of the "x"
// binding.
export { y as x } from './instn-named-star-cycle-2_.js';
export var y = 45;

View File

@ -0,0 +1,34 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Modules are visited no more than one time when resolving bindings through
"star" exports.
esid: sec-moduledeclarationinstantiation
info: |
[...]
12. For each ImportEntry Record in in module.[[ImportEntries]], do
a. Let importedModule be ? HostResolveImportedModule(module,
in.[[ModuleRequest]]).
b. If in.[[ImportName]] is "*", then
[...]
c. Else,
i. Let resolution be ?
importedModule.ResolveExport(in.[[ImportName]], « », « »).
ii. If resolution is null or resolution is "ambiguous", throw a
SyntaxError exception.
iii. Call envRec.CreateImportBinding(in.[[LocalName]],
resolution.[[Module]], resolution.[[BindingName]]).
[...]
15.2.1.16.3 ResolveExport( exportName, resolveSet, exportStarSet )
[...]
7. If exportStarSet contains module, return null.
8. Append module to exportStarSet.
[...]
negative: SyntaxError
flags: [module]
---*/
import { x } from './instn-named-star-cycle-2_.js';

View File

@ -0,0 +1,33 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Module is instantiated exactly once
esid: sec-moduledeclarationinstantiation
info: |
[...]
5. If module.[[Environment]] is not undefined, return
NormalCompletion(empty).
6. Let env be NewModuleEnvironment(realm.[[GlobalEnv]]).
7. Set module.[[Environment]] to env.
8. For each String required that is an element of
module.[[RequestedModules]] do,
a. NOTE: Before instantiating a module, all of the modules it requested
must be available. An implementation may perform this test at any
time prior to this point.
b. Let requiredModule be ? HostResolveImportedModule(module, required).
c. Perform ? requiredModule.ModuleDeclarationInstantiation().
[...]
flags: [module]
---*/
import {} from './instn-once.js';
import './instn-once.js';
import * as ns1 from './instn-once.js';
import dflt1 from './instn-once.js';
export {} from './instn-once.js';
import dflt2, {} from './instn-once.js';
export * from './instn-once.js';
import dflt3, * as ns from './instn-once.js';
export default null;
let x;

View File

@ -0,0 +1,36 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
An ExportClause without an ExportsList contributes to the list of requested
modules
esid: sec-moduledeclarationinstantiation
info: |
[...]
8. For each String required that is an element of
module.[[RequestedModules]] do,
a. NOTE: Before instantiating a module, all of the modules it requested
must be available. An implementation may perform this test at any
time prior to this point.
b. Let requiredModule be ? HostResolveImportedModule(module, required).
c. Perform ? requiredModule.ModuleDeclarationInstantiation().
15.2.2.5 Static Semantics: ModuleRequests
ImportDeclaration : import ImportClause FromClause;
1. Return ModuleRequests of FromClause.
15.2.3 Exports
Syntax
ExportClause:
{ }
{ ExportsList }
{ ExportsList , }
negative: ReferenceError
flags: [module]
---*/
export {} from './instn-resolve-empty-export_.js';

View File

@ -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.
0++;

View File

@ -0,0 +1,42 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
An ImportClause without an ImportsList contributes to the list of requested
modules
esid: sec-moduledeclarationinstantiation
info: |
[...]
8. For each String required that is an element of
module.[[RequestedModules]] do,
a. NOTE: Before instantiating a module, all of the modules it requested
must be available. An implementation may perform this test at any
time prior to this point.
b. Let requiredModule be ? HostResolveImportedModule(module, required).
c. Perform ? requiredModule.ModuleDeclarationInstantiation().
15.2.2.5 Static Semantics: ModuleRequests
ImportDeclaration : import ImportClause FromClause;
1. Return ModuleRequests of FromClause.
15.2.3 Exports
Syntax
ImportClause :
ImportedDefaultBinding
NameSpaceImport
NamedImports
ImportedDefaultBinding , NameSpaceImport
ImportedDefaultBinding , NamedImports
NamedImports :
{ }
{ ImportsList }
{ ImportsList , }
negative: ReferenceError
flags: [module]
---*/
import {} from './instn-resolve-empty-import_.js';

View File

@ -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.
0++;

View File

@ -0,0 +1,17 @@
// 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 that produce an early ReferenceError
esid: sec-moduledeclarationinstantiation
info: |
[...]
8. For each String required that is an element of
module.[[RequestedModules]] do,
[...]
b. Let requiredModule be ? HostResolveImportedModule(module, required).
[...]
negative: ReferenceError
flags: [module]
---*/
import './instn-resolve-err-reference_.js';

View File

@ -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.
0++;

View File

@ -0,0 +1,17 @@
// 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 that produce an early SyntaxError
esid: sec-moduledeclarationinstantiation
info: |
[...]
8. For each String required that is an element of
module.[[RequestedModules]] do,
[...]
b. Let requiredModule be ? HostResolveImportedModule(module, required).
[...]
negative: SyntaxError
flags: [module]
---*/
import './instn-resolve-err-syntax_.js';

View File

@ -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.
break;

View File

@ -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.
import './instn-resolve-order-depth-reference_.js';

View File

@ -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.
0++;

View File

@ -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.
break;

View File

@ -0,0 +1,11 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Module dependencies are resolved following a depth-first strategy
esid: sec-moduledeclarationinstantiation
negative: ReferenceError
flags: [module]
---*/
import './instn-resolve-order-depth-child_.js';
import './instn-resolve-order-depth-syntax_.js';

View File

@ -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.
0++;

View File

@ -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.
break;

View File

@ -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.
;

View File

@ -0,0 +1,12 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Modules dependencies are resolved in source text order
esid: sec-moduledeclarationinstantiation
negative: ReferenceError
flags: [module]
---*/
import './instn-resolve-order-src-valid_.js';
import './instn-resolve-order-src-reference_.js';
import './instn-resolve-order-src-syntax_.js';

Some files were not shown because too many files have changed in this diff Show More