mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
Merge pull request #562 from bocoup/modules-instn
Module semantics: declaration instantiation
This commit is contained in:
commit
d5c92d09f0
test/language/module-code
instn-iee-bndng-cls.jsinstn-iee-bndng-cls_FIXTURE.jsinstn-iee-bndng-const.jsinstn-iee-bndng-const_FIXTURE.jsinstn-iee-bndng-fun.jsinstn-iee-bndng-fun_FIXTURE.jsinstn-iee-bndng-gen.jsinstn-iee-bndng-gen_FIXTURE.jsinstn-iee-bndng-let.jsinstn-iee-bndng-let_FIXTURE.jsinstn-iee-bndng-var.jsinstn-iee-bndng-var_FIXTURE.jsinstn-iee-err-ambiguous-1_FIXTURE.jsinstn-iee-err-ambiguous-2_FIXTURE.jsinstn-iee-err-ambiguous-as.jsinstn-iee-err-ambiguous.jsinstn-iee-err-ambiguous_FIXTURE.jsinstn-iee-err-circular-as.jsinstn-iee-err-circular.jsinstn-iee-err-circular_FIXTURE.jsinstn-iee-err-dflt-thru-star-as.jsinstn-iee-err-dflt-thru-star-dflt_FIXTURE.jsinstn-iee-err-dflt-thru-star-int_FIXTURE.jsinstn-iee-err-dflt-thru-star.jsinstn-iee-err-not-found-as.jsinstn-iee-err-not-found-empty_FIXTURE.jsinstn-iee-err-not-found.jsinstn-iee-iee-cycle-2_FIXTURE.jsinstn-iee-iee-cycle.jsinstn-iee-star-cycle-2_FIXTURE.jsinstn-iee-star-cycle-indirect-x_FIXTURE.jsinstn-iee-star-cycle.jsinstn-iee-trlng-comma.jsinstn-iee-trlng-comma_FIXTURE.jsinstn-local-bndng-cls.jsinstn-local-bndng-const.jsinstn-local-bndng-export-cls.jsinstn-local-bndng-export-const.jsinstn-local-bndng-export-fun.jsinstn-local-bndng-export-gen.jsinstn-local-bndng-export-let.jsinstn-local-bndng-export-var.jsinstn-local-bndng-for-dup.jsinstn-local-bndng-for.jsinstn-local-bndng-fun.jsinstn-local-bndng-gen.jsinstn-local-bndng-let.jsinstn-local-bndng-var-dup.jsinstn-local-bndng-var.jsinstn-named-bndng-cls.jsinstn-named-bndng-const.jsinstn-named-bndng-dflt-cls.jsinstn-named-bndng-dflt-expr.jsinstn-named-bndng-dflt-fun-anon.jsinstn-named-bndng-dflt-fun-named.jsinstn-named-bndng-dflt-gen-anon.jsinstn-named-bndng-dflt-gen-named.jsinstn-named-bndng-dflt-named.jsinstn-named-bndng-dflt-star.jsinstn-named-bndng-fun.jsinstn-named-bndng-gen.jsinstn-named-bndng-let.jsinstn-named-bndng-trlng-comma.jsinstn-named-bndng-var.jsinstn-named-err-ambiguous-1_FIXTURE.jsinstn-named-err-ambiguous-2_FIXTURE.jsinstn-named-err-ambiguous-as.jsinstn-named-err-ambiguous.jsinstn-named-err-ambiguous_FIXTURE.jsinstn-named-err-dflt-thru-star-as.jsinstn-named-err-dflt-thru-star-dflt.jsinstn-named-err-dflt-thru-star-dflt_FIXTURE.jsinstn-named-err-dflt-thru-star-int_FIXTURE.jsinstn-named-err-not-found-as.jsinstn-named-err-not-found-dflt.jsinstn-named-err-not-found-empty_FIXTURE.jsinstn-named-err-not-found.jsinstn-named-id-name.jsinstn-named-iee-cycle-2_FIXTURE.jsinstn-named-iee-cycle.jsinstn-named-star-cycle-2_FIXTURE.jsinstn-named-star-cycle-indirect-x_FIXTURE.jsinstn-named-star-cycle.jsinstn-once.jsinstn-resolve-empty-export.jsinstn-resolve-empty-export_FIXTURE.jsinstn-resolve-empty-import.jsinstn-resolve-empty-import_FIXTURE.jsinstn-resolve-err-reference.jsinstn-resolve-err-reference_FIXTURE.jsinstn-resolve-err-syntax.jsinstn-resolve-err-syntax_FIXTURE.jsinstn-resolve-order-depth-child_FIXTURE.jsinstn-resolve-order-depth-reference_FIXTURE.jsinstn-resolve-order-depth-syntax_FIXTURE.jsinstn-resolve-order-depth.jsinstn-resolve-order-src-reference_FIXTURE.jsinstn-resolve-order-src-syntax_FIXTURE.jsinstn-resolve-order-src-valid_FIXTURE.jsinstn-resolve-order-src.js
47
test/language/module-code/instn-iee-bndng-cls.js
Normal file
47
test/language/module-code/instn-iee-bndng-cls.js
Normal 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_FIXTURE.js';
|
||||
export class A {}
|
18
test/language/module-code/instn-iee-bndng-cls_FIXTURE.js
Normal file
18
test/language/module-code/instn-iee-bndng-cls_FIXTURE.js
Normal 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');
|
47
test/language/module-code/instn-iee-bndng-const.js
Normal file
47
test/language/module-code/instn-iee-bndng-const.js
Normal 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_FIXTURE.js';
|
||||
export const x = null;
|
18
test/language/module-code/instn-iee-bndng-const_FIXTURE.js
Normal file
18
test/language/module-code/instn-iee-bndng-const_FIXTURE.js
Normal 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');
|
55
test/language/module-code/instn-iee-bndng-fun.js
Normal file
55
test/language/module-code/instn-iee-bndng-fun.js
Normal 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_FIXTURE.js';
|
||||
export function f() { return 77; }
|
18
test/language/module-code/instn-iee-bndng-fun_FIXTURE.js
Normal file
18
test/language/module-code/instn-iee-bndng-fun_FIXTURE.js
Normal 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');
|
56
test/language/module-code/instn-iee-bndng-gen.js
Normal file
56
test/language/module-code/instn-iee-bndng-gen.js
Normal 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_FIXTURE.js';
|
||||
export function* g () { return 455; }
|
18
test/language/module-code/instn-iee-bndng-gen_FIXTURE.js
Normal file
18
test/language/module-code/instn-iee-bndng-gen_FIXTURE.js
Normal 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');
|
47
test/language/module-code/instn-iee-bndng-let.js
Normal file
47
test/language/module-code/instn-iee-bndng-let.js
Normal 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_FIXTURE.js';
|
||||
export let x;
|
18
test/language/module-code/instn-iee-bndng-let_FIXTURE.js
Normal file
18
test/language/module-code/instn-iee-bndng-let_FIXTURE.js
Normal 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');
|
55
test/language/module-code/instn-iee-bndng-var.js
Normal file
55
test/language/module-code/instn-iee-bndng-var.js
Normal 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_FIXTURE.js';
|
||||
export var x = 99;
|
18
test/language/module-code/instn-iee-bndng-var_FIXTURE.js
Normal file
18
test/language/module-code/instn-iee-bndng-var_FIXTURE.js
Normal 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');
|
@ -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;
|
@ -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;
|
37
test/language/module-code/instn-iee-err-ambiguous-as.js
Normal file
37
test/language/module-code/instn-iee-err-ambiguous-as.js
Normal 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_FIXTURE.js';
|
37
test/language/module-code/instn-iee-err-ambiguous.js
Normal file
37
test/language/module-code/instn-iee-err-ambiguous.js
Normal 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_FIXTURE.js';
|
@ -0,0 +1,5 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
export * from './instn-iee-err-ambiguous-1_FIXTURE.js';
|
||||
export * from './instn-iee-err-ambiguous-2_FIXTURE.js';
|
26
test/language/module-code/instn-iee-err-circular-as.js
Normal file
26
test/language/module-code/instn-iee-err-circular-as.js
Normal 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_FIXTURE.js';
|
26
test/language/module-code/instn-iee-err-circular.js
Normal file
26
test/language/module-code/instn-iee-err-circular.js
Normal 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_FIXTURE.js';
|
@ -0,0 +1,4 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
export { x } from './instn-iee-err-circular.js';
|
25
test/language/module-code/instn-iee-err-dflt-thru-star-as.js
Normal file
25
test/language/module-code/instn-iee-err-dflt-thru-star-as.js
Normal 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_FIXTURE.js';
|
@ -0,0 +1,5 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
var x;
|
||||
export { x as default };
|
@ -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_FIXTURE.js';
|
25
test/language/module-code/instn-iee-err-dflt-thru-star.js
Normal file
25
test/language/module-code/instn-iee-err-dflt-thru-star.js
Normal 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_FIXTURE.js';
|
25
test/language/module-code/instn-iee-err-not-found-as.js
Normal file
25
test/language/module-code/instn-iee-err-not-found-as.js
Normal 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_FIXTURE.js';
|
@ -0,0 +1,4 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
;
|
25
test/language/module-code/instn-iee-err-not-found.js
Normal file
25
test/language/module-code/instn-iee-err-not-found.js
Normal 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_FIXTURE.js';
|
16
test/language/module-code/instn-iee-iee-cycle-2_FIXTURE.js
Normal file
16
test/language/module-code/instn-iee-iee-cycle-2_FIXTURE.js
Normal 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';
|
49
test/language/module-code/instn-iee-iee-cycle.js
Normal file
49
test/language/module-code/instn-iee-iee-cycle.js
Normal 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_FIXTURE.js';
|
||||
export { c as b } from './instn-iee-iee-cycle-2_FIXTURE.js';
|
||||
export { e as d } from './instn-iee-iee-cycle-2_FIXTURE.js';
|
||||
export { g as f } from './instn-iee-iee-cycle-2_FIXTURE.js';
|
||||
export { i as h } from './instn-iee-iee-cycle-2_FIXTURE.js';
|
||||
export { k as j } from './instn-iee-iee-cycle-2_FIXTURE.js';
|
||||
export { m as l } from './instn-iee-iee-cycle-2_FIXTURE.js';
|
||||
export { o as n } from './instn-iee-iee-cycle-2_FIXTURE.js';
|
||||
export { q as p } from './instn-iee-iee-cycle-2_FIXTURE.js';
|
||||
export { s as r } from './instn-iee-iee-cycle-2_FIXTURE.js';
|
||||
export { u as t } from './instn-iee-iee-cycle-2_FIXTURE.js';
|
||||
export { w as v } from './instn-iee-iee-cycle-2_FIXTURE.js';
|
||||
export { y as x } from './instn-iee-iee-cycle-2_FIXTURE.js';
|
||||
export var z;
|
@ -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_FIXTURE.js';
|
@ -0,0 +1,7 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// This module should be visited exactly one time during resolution of the "x"
|
||||
// binding.
|
||||
export { y as x } from './instn-iee-star-cycle-2_FIXTURE.js';
|
||||
export var y = 45;
|
25
test/language/module-code/instn-iee-star-cycle.js
Normal file
25
test/language/module-code/instn-iee-star-cycle.js
Normal 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_FIXTURE.js';
|
21
test/language/module-code/instn-iee-trlng-comma.js
Normal file
21
test/language/module-code/instn-iee-trlng-comma.js
Normal 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_FIXTURE.js';
|
||||
export { a as b , } from './instn-iee-trlng-comma_FIXTURE.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');
|
@ -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;
|
44
test/language/module-code/instn-local-bndng-cls.js
Normal file
44
test/language/module-code/instn-local-bndng-cls.js
Normal 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'
|
||||
);
|
44
test/language/module-code/instn-local-bndng-const.js
Normal file
44
test/language/module-code/instn-local-bndng-const.js
Normal 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'
|
||||
);
|
30
test/language/module-code/instn-local-bndng-export-cls.js
Normal file
30
test/language/module-code/instn-local-bndng-export-cls.js
Normal 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 {}
|
29
test/language/module-code/instn-local-bndng-export-const.js
Normal file
29
test/language/module-code/instn-local-bndng-export-const.js
Normal 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;
|
32
test/language/module-code/instn-local-bndng-export-fun.js
Normal file
32
test/language/module-code/instn-local-bndng-export-fun.js
Normal 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; }
|
32
test/language/module-code/instn-local-bndng-export-gen.js
Normal file
32
test/language/module-code/instn-local-bndng-export-gen.js
Normal 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; }
|
29
test/language/module-code/instn-local-bndng-export-let.js
Normal file
29
test/language/module-code/instn-local-bndng-export-let.js
Normal 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;
|
32
test/language/module-code/instn-local-bndng-export-var.js
Normal file
32
test/language/module-code/instn-local-bndng-export-var.js
Normal 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;
|
23
test/language/module-code/instn-local-bndng-for-dup.js
Normal file
23
test/language/module-code/instn-local-bndng-for-dup.js
Normal 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; ) {}
|
36
test/language/module-code/instn-local-bndng-for.js
Normal file
36
test/language/module-code/instn-local-bndng-for.js
Normal 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'
|
||||
);
|
49
test/language/module-code/instn-local-bndng-fun.js
Normal file
49
test/language/module-code/instn-local-bndng-fun.js
Normal 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'
|
||||
);
|
50
test/language/module-code/instn-local-bndng-gen.js
Normal file
50
test/language/module-code/instn-local-bndng-gen.js
Normal 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'
|
||||
);
|
44
test/language/module-code/instn-local-bndng-let.js
Normal file
44
test/language/module-code/instn-local-bndng-let.js
Normal 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'
|
||||
);
|
23
test/language/module-code/instn-local-bndng-var-dup.js
Normal file
23
test/language/module-code/instn-local-bndng-var-dup.js
Normal 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;
|
37
test/language/module-code/instn-local-bndng-var.js
Normal file
37
test/language/module-code/instn-local-bndng-var.js
Normal 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'
|
||||
);
|
46
test/language/module-code/instn-named-bndng-cls.js
Normal file
46
test/language/module-code/instn-named-bndng-cls.js
Normal 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 {}
|
46
test/language/module-code/instn-named-bndng-const.js
Normal file
46
test/language/module-code/instn-named-bndng-const.js
Normal 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;
|
39
test/language/module-code/instn-named-bndng-dflt-cls.js
Normal file
39
test/language/module-code/instn-named-bndng-dflt-cls.js
Normal 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';
|
37
test/language/module-code/instn-named-bndng-dflt-expr.js
Normal file
37
test/language/module-code/instn-named-bndng-dflt-expr.js
Normal 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() {});
|
50
test/language/module-code/instn-named-bndng-dflt-fun-anon.js
Normal file
50
test/language/module-code/instn-named-bndng-dflt-fun-anon.js
Normal 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; };
|
@ -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; };
|
52
test/language/module-code/instn-named-bndng-dflt-gen-anon.js
Normal file
52
test/language/module-code/instn-named-bndng-dflt-gen-anon.js
Normal 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; };
|
@ -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; };
|
27
test/language/module-code/instn-named-bndng-dflt-named.js
Normal file
27
test/language/module-code/instn-named-bndng-dflt-named.js
Normal 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';
|
28
test/language/module-code/instn-named-bndng-dflt-star.js
Normal file
28
test/language/module-code/instn-named-bndng-dflt-star.js
Normal 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';
|
57
test/language/module-code/instn-named-bndng-fun.js
Normal file
57
test/language/module-code/instn-named-bndng-fun.js
Normal 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; }
|
58
test/language/module-code/instn-named-bndng-gen.js
Normal file
58
test/language/module-code/instn-named-bndng-gen.js
Normal 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; }
|
46
test/language/module-code/instn-named-bndng-let.js
Normal file
46
test/language/module-code/instn-named-bndng-let.js
Normal 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;
|
54
test/language/module-code/instn-named-bndng-trlng-comma.js
Normal file
54
test/language/module-code/instn-named-bndng-trlng-comma.js
Normal 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;
|
52
test/language/module-code/instn-named-bndng-var.js
Normal file
52
test/language/module-code/instn-named-bndng-var.js
Normal 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;
|
@ -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;
|
@ -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;
|
42
test/language/module-code/instn-named-err-ambiguous-as.js
Normal file
42
test/language/module-code/instn-named-err-ambiguous-as.js
Normal 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_FIXTURE.js';
|
42
test/language/module-code/instn-named-err-ambiguous.js
Normal file
42
test/language/module-code/instn-named-err-ambiguous.js
Normal 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_FIXTURE.js';
|
@ -0,0 +1,5 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
export * from './instn-named-err-ambiguous-1_FIXTURE.js';
|
||||
export * from './instn-named-err-ambiguous-2_FIXTURE.js';
|
@ -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_FIXTURE.js';
|
@ -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_FIXTURE.js';
|
@ -0,0 +1,5 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
var x;
|
||||
export { x as default };
|
@ -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_FIXTURE.js';
|
30
test/language/module-code/instn-named-err-not-found-as.js
Normal file
30
test/language/module-code/instn-named-err-not-found-as.js
Normal 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_FIXTURE.js';
|
30
test/language/module-code/instn-named-err-not-found-dflt.js
Normal file
30
test/language/module-code/instn-named-err-not-found-dflt.js
Normal 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_FIXTURE.js';
|
@ -0,0 +1,4 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
;
|
30
test/language/module-code/instn-named-err-not-found.js
Normal file
30
test/language/module-code/instn-named-err-not-found.js
Normal 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_FIXTURE.js';
|
53
test/language/module-code/instn-named-id-name.js
Normal file
53
test/language/module-code/instn-named-id-name.js
Normal 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);
|
16
test/language/module-code/instn-named-iee-cycle-2_FIXTURE.js
Normal file
16
test/language/module-code/instn-named-iee-cycle-2_FIXTURE.js
Normal 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';
|
60
test/language/module-code/instn-named-iee-cycle.js
Normal file
60
test/language/module-code/instn-named-iee-cycle.js
Normal 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_FIXTURE.js';
|
||||
export { c as b } from './instn-named-iee-cycle-2_FIXTURE.js';
|
||||
export { e as d } from './instn-named-iee-cycle-2_FIXTURE.js';
|
||||
export { g as f } from './instn-named-iee-cycle-2_FIXTURE.js';
|
||||
export { i as h } from './instn-named-iee-cycle-2_FIXTURE.js';
|
||||
export { k as j } from './instn-named-iee-cycle-2_FIXTURE.js';
|
||||
export { m as l } from './instn-named-iee-cycle-2_FIXTURE.js';
|
||||
export { o as n } from './instn-named-iee-cycle-2_FIXTURE.js';
|
||||
export { q as p } from './instn-named-iee-cycle-2_FIXTURE.js';
|
||||
export { s as r } from './instn-named-iee-cycle-2_FIXTURE.js';
|
||||
export { u as t } from './instn-named-iee-cycle-2_FIXTURE.js';
|
||||
export { w as v } from './instn-named-iee-cycle-2_FIXTURE.js';
|
||||
export { y as x } from './instn-named-iee-cycle-2_FIXTURE.js';
|
||||
export var z = 23;
|
||||
|
||||
assert.sameValue(a, 23);
|
@ -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_FIXTURE.js';
|
@ -0,0 +1,7 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// This module should be visited exactly one time during resolution of the "x"
|
||||
// binding.
|
||||
export { y as x } from './instn-named-star-cycle-2_FIXTURE.js';
|
||||
export var y = 45;
|
34
test/language/module-code/instn-named-star-cycle.js
Normal file
34
test/language/module-code/instn-named-star-cycle.js
Normal 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_FIXTURE.js';
|
33
test/language/module-code/instn-once.js
Normal file
33
test/language/module-code/instn-once.js
Normal 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;
|
36
test/language/module-code/instn-resolve-empty-export.js
Normal file
36
test/language/module-code/instn-resolve-empty-export.js
Normal 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_FIXTURE.js';
|
@ -0,0 +1,4 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
0++;
|
42
test/language/module-code/instn-resolve-empty-import.js
Normal file
42
test/language/module-code/instn-resolve-empty-import.js
Normal 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_FIXTURE.js';
|
@ -0,0 +1,4 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
0++;
|
17
test/language/module-code/instn-resolve-err-reference.js
Normal file
17
test/language/module-code/instn-resolve-err-reference.js
Normal 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_FIXTURE.js';
|
@ -0,0 +1,4 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
0++;
|
17
test/language/module-code/instn-resolve-err-syntax.js
Normal file
17
test/language/module-code/instn-resolve-err-syntax.js
Normal 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_FIXTURE.js';
|
@ -0,0 +1,4 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
break;
|
@ -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_FIXTURE.js';
|
@ -0,0 +1,4 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
0++;
|
@ -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;
|
11
test/language/module-code/instn-resolve-order-depth.js
Normal file
11
test/language/module-code/instn-resolve-order-depth.js
Normal 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_FIXTURE.js';
|
||||
import './instn-resolve-order-depth-syntax_FIXTURE.js';
|
@ -0,0 +1,4 @@
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
0++;
|
@ -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;
|
@ -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.
|
||||
|
||||
;
|
12
test/language/module-code/instn-resolve-order-src.js
Normal file
12
test/language/module-code/instn-resolve-order-src.js
Normal 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_FIXTURE.js';
|
||||
import './instn-resolve-order-src-reference_FIXTURE.js';
|
||||
import './instn-resolve-order-src-syntax_FIXTURE.js';
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user