Merge pull request #563 from bocoup/modules-eval

Module semantics: evaluation
This commit is contained in:
Gorkem Yakin 2016-04-29 14:26:01 -07:00
commit 583a83c202
51 changed files with 1063 additions and 0 deletions

View File

@ -0,0 +1,15 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
An exported class declaration does not need to be terminated with a
semicolon or newline
esid: sec-moduleevaluation
flags: [module]
---*/
var count = 0;
export class C {} if (true) { count += 1; }
assert.sameValue(count, 1);

View File

@ -0,0 +1,15 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
An exported default "anonymous" class declaration does not need to be
terminated with a semicolon or newline
esid: sec-moduleevaluation
flags: [module]
---*/
var count = 0;
export default class {} if (true) { count += 1; }
assert.sameValue(count, 1);

View File

@ -0,0 +1,33 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Default "anonymous" class declaration is correctly initialized upon
evaluation
esid: sec-moduleevaluation
info: |
[...]
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
[...]
15.2.3.11 Runtime Semantics: Evaluation
ExportDeclaration : export default ClassDeclaration
[...]
3. Let className be the sole element of BoundNames of ClassDeclaration.
4. If className is "*default*", then
a. Let hasNameProperty be ? HasOwnProperty(value, "name").
b. If hasNameProperty is false, perform SetFunctionName(value,
"default").
c. Let env be the running execution context's LexicalEnvironment.
d. Perform ? InitializeBoundName("*default*", value, env).
5. Return NormalCompletion(empty).
flags: [module]
---*/
export default class { valueOf() { return 45; } }
import C from './eval-export-dflt-cls-anon.js';
assert.sameValue(new C().valueOf(), 45, 'binding initialized');
assert.sameValue(C.name, 'default', 'correct name is assigned');

View File

@ -0,0 +1,34 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Default "anonymous" class declaration containing a static `name` method is
correctly initialized upon evaluation
esid: sec-moduleevaluation
info: |
[...]
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
[...]
15.2.3.11 Runtime Semantics: Evaluation
ExportDeclaration : export default ClassDeclaration
[...]
3. Let className be the sole element of BoundNames of ClassDeclaration.
4. If className is "*default*", then
a. Let hasNameProperty be ? HasOwnProperty(value, "name").
b. If hasNameProperty is false, perform SetFunctionName(value,
"default").
c. Let env be the running execution context's LexicalEnvironment.
d. Perform ? InitializeBoundName("*default*", value, env).
5. Return NormalCompletion(empty).
flags: [module]
---*/
export default class { static name() { return 'name method'; } }
import C from './eval-export-dflt-cls-name-meth.js';
assert.sameValue(
C.name(), 'name method', '`name` property is not over-written'
);

View File

@ -0,0 +1,15 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
An exported default "named" class declaration does not need to be
terminated with a semicolon or newline
esid: sec-moduleevaluation
flags: [module]
---*/
var count = 0;
export default class C {} if (true) { count += 1; }
assert.sameValue(count, 1);

View File

@ -0,0 +1,33 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Default "named" class declaration is correctly initialized upon
evaluation
esid: sec-moduleevaluation
info: |
[...]
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
[...]
15.2.3.11 Runtime Semantics: Evaluation
ExportDeclaration : export default ClassDeclaration
[...]
3. Let className be the sole element of BoundNames of ClassDeclaration.
4. If className is "*default*", then
a. Let hasNameProperty be ? HasOwnProperty(value, "name").
b. If hasNameProperty is false, perform SetFunctionName(value,
"default").
c. Let env be the running execution context's LexicalEnvironment.
d. Perform ? InitializeBoundName("*default*", value, env).
5. Return NormalCompletion(empty).
flags: [module]
---*/
export default class cName { valueOf() { return 45; } }
import C from './eval-export-dflt-cls-named.js';
assert.sameValue(new C().valueOf(), 45, 'binding initialized');
assert.sameValue(C.name, 'cName', 'correct name is assigned');

View File

@ -0,0 +1,32 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Default AssignmentExpression (which can be recognized as an "anonymous"
class declaration) is correctly initialized upon evaluation
esid: sec-moduleevaluation
info: |
[...]
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
[...]
15.2.3.11 Runtime Semantics: Evaluation
ExportDeclaration : export default AssignmentExpression;
[...]
3. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then
a. Let hasNameProperty be ? HasOwnProperty(value, "name").
b. If hasNameProperty is false, perform SetFunctionName(value,
"default").
4. Let env be the running execution context's LexicalEnvironment.
5. Perform ? InitializeBoundName("*default*", value, env).
[...]
flags: [module]
---*/
export default (class { valueOf() { return 45; } });
import C from './eval-export-dflt-expr-cls-anon.js';
assert.sameValue(new C().valueOf(), 45, 'binding initialized');
assert.sameValue(C.name, 'default', 'correct name is assigned');

View File

@ -0,0 +1,35 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Default AssignmentExpression (which can be recognized as an "anonymous"
class declaration with a static `name` method) is correctly initialized
upon evaluation
esid: sec-moduleevaluation
info: |
[...]
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
[...]
15.2.3.11 Runtime Semantics: Evaluation
ExportDeclaration : export default ClassDeclaration
[...]
3. Let className be the sole element of BoundNames of ClassDeclaration.
4. If className is "*default*", then
a. Let hasNameProperty be ? HasOwnProperty(value, "name").
b. If hasNameProperty is false, perform SetFunctionName(value,
"default").
c. Let env be the running execution context's LexicalEnvironment.
d. Perform ? InitializeBoundName("*default*", value, env).
5. Return NormalCompletion(empty).
flags: [module]
---*/
export default (class { static name() { return 'name method'; } });
import C from './eval-export-dflt-expr-cls-name-meth.js';
assert.sameValue(
C.name(), 'name method', '`name` property is not over-written'
);

View File

@ -0,0 +1,32 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Default AssignmentExpression (which can be recognized as a "named" class
declaration) is correctly initialized upon evaluation
esid: sec-moduleevaluation
info: |
[...]
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
[...]
15.2.3.11 Runtime Semantics: Evaluation
ExportDeclaration : export default AssignmentExpression;
[...]
3. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then
a. Let hasNameProperty be ? HasOwnProperty(value, "name").
b. If hasNameProperty is false, perform SetFunctionName(value,
"default").
4. Let env be the running execution context's LexicalEnvironment.
5. Perform ? InitializeBoundName("*default*", value, env).
[...]
flags: [module]
---*/
export default (class cName { valueOf() { return 45; } });
import C from './eval-export-dflt-expr-cls-named.js';
assert.sameValue(new C().valueOf(), 45, 'binding initialized');
assert.sameValue(C.name, 'cName', 'correct name is assigned');

View File

@ -0,0 +1,31 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Abrupt completions resulting from evaluation on AssignmentExpression are
forwarded to the runtime.
esid: sec-moduleevaluation
info: |
[...]
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
[...]
15.2.3.11 Runtime Semantics: Evaluation
ExportDeclaration : export default AssignmentExpression;
[...]
1. Let rhs be the result of evaluating AssignmentExpression.
2. Let value be ? GetValue(rhs).
6.2.3.1 GetValue (V)
1. ReturnIfAbrupt(V).
2. If Type(V) is not Reference, return V.
3. Let base be GetBase(V).
4. If IsUnresolvableReference(V) is true, throw a ReferenceError exception.
negative: Test262Error
flags: [module]
---*/
export default (function() { throw new Test262Error(); })();

View File

@ -0,0 +1,31 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Abrupt completions resulting from value retrieval are forwarded to the
runtime.
esid: sec-moduleevaluation
info: |
[...]
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
[...]
15.2.3.11 Runtime Semantics: Evaluation
ExportDeclaration : export default AssignmentExpression;
[...]
1. Let rhs be the result of evaluating AssignmentExpression.
2. Let value be ? GetValue(rhs).
6.2.3.1 GetValue (V)
1. ReturnIfAbrupt(V).
2. If Type(V) is not Reference, return V.
3. Let base be GetBase(V).
4. If IsUnresolvableReference(V) is true, throw a ReferenceError exception.
negative: ReferenceError
flags: [module]
---*/
export default unresolvable;

View File

@ -0,0 +1,32 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Default AssignmentExpression (which can be recognized as an "anonymous"
function declaration) is correctly initialized upon evaluation
esid: sec-moduleevaluation
info: |
[...]
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
[...]
15.2.3.11 Runtime Semantics: Evaluation
ExportDeclaration : export default AssignmentExpression;
[...]
3. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then
a. Let hasNameProperty be ? HasOwnProperty(value, "name").
b. If hasNameProperty is false, perform SetFunctionName(value,
"default").
4. Let env be the running execution context's LexicalEnvironment.
5. Perform ? InitializeBoundName("*default*", value, env).
[...]
flags: [module]
---*/
export default (function() { return 99; });
import f from './eval-export-dflt-expr-fn-anon.js';
assert.sameValue(f(), 99, 'binding initialized');
assert.sameValue(f.name, 'default', 'correct name is assigned');

View File

@ -0,0 +1,32 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Default AssignmentExpression (which can be recognized as a "named" function
declaration) is correctly initialized upon evaluation
esid: sec-moduleevaluation
info: |
[...]
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
[...]
15.2.3.11 Runtime Semantics: Evaluation
ExportDeclaration : export default AssignmentExpression;
[...]
3. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then
a. Let hasNameProperty be ? HasOwnProperty(value, "name").
b. If hasNameProperty is false, perform SetFunctionName(value,
"default").
4. Let env be the running execution context's LexicalEnvironment.
5. Perform ? InitializeBoundName("*default*", value, env).
[...]
flags: [module]
---*/
export default (function fName() { return 7; });
import f from './eval-export-dflt-expr-fn-named.js';
assert.sameValue(f(), 7, 'binding initialized');
assert.sameValue(f.name, 'fName', 'correct name is assigned');

View File

@ -0,0 +1,32 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Default AssignmentExpression (which can be recognized as an "anonymous"
generator function declaration) is correctly initialized upon evaluation
esid: sec-moduleevaluation
info: |
[...]
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
[...]
15.2.3.11 Runtime Semantics: Evaluation
ExportDeclaration : export default AssignmentExpression;
[...]
3. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then
a. Let hasNameProperty be ? HasOwnProperty(value, "name").
b. If hasNameProperty is false, perform SetFunctionName(value,
"default").
4. Let env be the running execution context's LexicalEnvironment.
5. Perform ? InitializeBoundName("*default*", value, env).
[...]
flags: [module]
---*/
export default (function* () { return 24601; });
import g from './eval-export-dflt-expr-gen-anon.js';
assert.sameValue(g().next().value, 24601, 'binding initialized');
assert.sameValue(g.name, 'default', 'correct name is assigned');

View File

@ -0,0 +1,32 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Default AssignmentExpression (which can be recognized as a "named"
generator function declaration) is correctly initialized upon evaluation
esid: sec-moduleevaluation
info: |
[...]
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
[...]
15.2.3.11 Runtime Semantics: Evaluation
ExportDeclaration : export default AssignmentExpression;
[...]
3. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then
a. Let hasNameProperty be ? HasOwnProperty(value, "name").
b. If hasNameProperty is false, perform SetFunctionName(value,
"default").
4. Let env be the running execution context's LexicalEnvironment.
5. Perform ? InitializeBoundName("*default*", value, env).
[...]
flags: [module]
---*/
export default (function* gName() { return 88; });
import g from './eval-export-dflt-expr-gen-named.js';
assert.sameValue(g().next().value, 88, 'binding initialized');
assert.sameValue(g.name, 'gName', 'correct name is assigned');

View File

@ -0,0 +1,27 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
The `in` operator may occur within an exported AssignmentExpression
esid: sec-moduleevaluation
info: |
[...]
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
[...]
15.2.3 Exports
Syntax
ExportDeclaration :
export default [lookahead { function, class }] AssignmentExpression[In];
flags: [module]
---*/
var x = { x: true };
export default 'x' in x;
import f from './eval-export-dflt-expr-in.js';
assert.sameValue(f, true);

View File

@ -0,0 +1,15 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
An exported default "anonymous" function declaration does not need to be
terminated with a semicolon or newline
esid: sec-moduleevaluation
flags: [module]
---*/
var count = 0;
export default function() {} if (true) { count += 1; }
assert.sameValue(count, 1);

View File

@ -0,0 +1,15 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
An exported default "named" function declaration does not need to be
terminated with a semicolon or newline
esid: sec-moduleevaluation
flags: [module]
---*/
var count = 0;
export default function f() {} if (true) { count += 1; }
assert.sameValue(count, 1);

View File

@ -0,0 +1,15 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
An exported default "anonymous" generator function declaration does not
need to be terminated with a semicolon or newline
esid: sec-moduleevaluation
flags: [module]
---*/
var count = 0;
export default function* () {} if (true) { count += 1; }
assert.sameValue(count, 1);

View File

@ -0,0 +1,15 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
An exported default "named" generator function declaration does not need to
be terminated with a semicolon or newline
esid: sec-moduleevaluation
flags: [module]
---*/
var count = 0;
export default function* g() {} if (true) { count += 1; }
assert.sameValue(count, 1);

View File

@ -0,0 +1,15 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
An exported function declaration does not need to be terminated with a
semicolon or newline
esid: sec-moduleevaluation
flags: [module]
---*/
var count = 0;
export function f() {} if (true) { count += 1; }
assert.sameValue(count, 1);

View File

@ -0,0 +1,15 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
An exported generator function declaration does not need to be terminated
with a semicolon or newline
esid: sec-moduleevaluation
flags: [module]
---*/
var count = 0;
export function* g() {} if (true) { count += 1; }
assert.sameValue(count, 1);

View File

@ -0,0 +1,23 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
NamedImports in ImportDeclaration may contain a trailing comma
esid: sec-moduleevaluation
info: |
8.1.1.5.1 GetBindingValue (N, S)
[...]
3. If the binding for N is an indirect binding, then
a. Let M and N2 be the indirection values provided when this binding for
N was created.
b. Let targetEnv be M.[[Environment]].
c. If targetEnv is undefined, throw a ReferenceError exception.
d. Let targetER be targetEnv's EnvironmentRecord.
e. Return ? targetER.GetBindingValue(N2, S).
flags: [module]
---*/
import { x , } from './eval-gtbndng-indirect-trlng-comma_FIXTURE.js';
assert.sameValue(x, 1);

View File

@ -0,0 +1,4 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
export var x = 1;

View File

@ -0,0 +1,34 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Modifications to named bindings that occur after dependency has been
evaluated are reflected in local binding
esid: sec-moduleevaluation
info: |
8.1.1.5.1 GetBindingValue (N, S)
[...]
3. If the binding for N is an indirect binding, then
a. Let M and N2 be the indirection values provided when this binding for
N was created.
b. Let targetEnv be M.[[Environment]].
c. If targetEnv is undefined, throw a ReferenceError exception.
d. Let targetER be targetEnv's EnvironmentRecord.
e. Return ? targetER.GetBindingValue(N2, S).
includes: [fnGlobalObject.js]
flags: [module]
---*/
import { x as y, x as z } from './eval-gtbndng-indirect-update-as_FIXTURE.js';
assert.sameValue(y, 1);
assert.sameValue(z, 1);
// This function is exposed on the global scope (instead of as an exported
// binding) in order to avoid possible false positives from assuming correct
// behavior of the semantics under test.
fnGlobalObject().test262update();
assert.sameValue(y, 2);
assert.sameValue(z, 2);

View File

@ -0,0 +1,9 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
var x = 1;
export { x };
Function('return this;')().test262update = function() {
x = 2;
};

View File

@ -0,0 +1,24 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Modifications to default binding that occur after dependency has been
evaluated are reflected in local binding
info: |
8.1.1.5.1 GetBindingValue (N, S)
[...]
3. If the binding for N is an indirect binding, then
a. Let M and N2 be the indirection values provided when this binding for
N was created.
b. Let targetEnv be M.[[Environment]].
c. If targetEnv is undefined, throw a ReferenceError exception.
d. Let targetER be targetEnv's EnvironmentRecord.
e. Return ? targetER.GetBindingValue(N2, S).
flags: [module]
---*/
import val from './eval-gtbndng-indirect-update-dflt_FIXTURE.js';
assert.sameValue(val(), 1);
assert.sameValue(val, 2);

View File

@ -0,0 +1,7 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
export default function fn() {
fn = 2;
return 1;
}

View File

@ -0,0 +1,32 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Modifications to named bindings that occur after dependency has been
evaluated are reflected in local binding
esid: sec-moduleevaluation
info: |
8.1.1.5.1 GetBindingValue (N, S)
[...]
3. If the binding for N is an indirect binding, then
a. Let M and N2 be the indirection values provided when this binding for
N was created.
b. Let targetEnv be M.[[Environment]].
c. If targetEnv is undefined, throw a ReferenceError exception.
d. Let targetER be targetEnv's EnvironmentRecord.
e. Return ? targetER.GetBindingValue(N2, S).
includes: [fnGlobalObject.js]
flags: [module]
---*/
import { x } from './eval-gtbndng-indirect-update_FIXTURE.js';
assert.sameValue(x, 1);
// This function is exposed on the global scope (instead of as an exported
// binding) in order to avoid possible false positives from assuming correct
// behavior of the semantics under test.
fnGlobalObject().test262update();
assert.sameValue(x, 2);

View File

@ -0,0 +1,9 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
var x = 1;
export { x };
Function('return this;')().test262update = function() {
x = 2;
};

View File

@ -0,0 +1,35 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: References to local `let` bindings resolve successfully
esid: sec-moduleevaluation
info: |
8.1.1.5.1 GetBindingValue (N, S)
[...]
3. If the binding for N is an indirect binding, then
[...]
5. Return the value currently bound to N in envRec.
14.5.16 Runtime Semantics: Evaluation
ClassDeclaration : class BindingIdentifier ClassTail
1. Let status be the result of BindingClassDeclarationEvaluation of this
ClassDeclaration.
2. ReturnIfAbrupt(status).
3. Return NormalCompletion(empty).
14.5.15 Runtime Semantics: BindingClassDeclarationEvaluation
[...]
7. Perform ? InitializeBoundName(className, value, env).
[...]
flags: [module]
---*/
class classBinding { valueOf() { return 33; } }
assert.sameValue(new classBinding().valueOf(), 33);
classBinding = 44;
assert.sameValue(classBinding, 44);

View File

@ -0,0 +1,24 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: References to local `const` bindings resolve successfully
esid: sec-moduleevaluation
info: |
8.1.1.5.1 GetBindingValue (N, S)
[...]
3. If the binding for N is an indirect binding, then
[...]
5. Return the value currently bound to N in envRec.
13.3.1.4 Runtime Semantics: Evaluation
LexicalBinding : BindingIdentifier Initializer
[...]
6. Return InitializeReferencedBinding(lhs, value).
flags: [module]
---*/
const constBinding = 89;
assert.sameValue(constBinding, 89);

View File

@ -0,0 +1,27 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: References to local `let` bindings resolve successfully
esid: sec-moduleevaluation
info: |
8.1.1.5.1 GetBindingValue (N, S)
[...]
3. If the binding for N is an indirect binding, then
[...]
5. Return the value currently bound to N in envRec.
13.3.1.4 Runtime Semantics: Evaluation
LexicalBinding : BindingIdentifier Initializer
[...]
6. Return InitializeReferencedBinding(lhs, value).
flags: [module]
---*/
let letBinding = 1;
assert.sameValue(letBinding, 1);
letBinding = 2;
assert.sameValue(letBinding, 2);

View File

@ -0,0 +1,40 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: References to local `var` bindings resolve successfully
esid: sec-moduleevaluation
info: |
8.1.1.5.1 GetBindingValue (N, S)
[...]
3. If the binding for N is an indirect binding, then
[...]
5. Return the value currently bound to N in envRec.
15.2.1.16.4 ModuleDeclarationInstantiation( )
[...]
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.
[...]
13.3.2.4 Runtime Semantics: Evaluation
VariableDeclaration : BindingIdentifier Initializer
[...]
6. Return ? PutValue(lhs, value).
flags: [module]
---*/
var varBinding = 1;
assert.sameValue(varBinding, 1);
varBinding = 2;
assert.sameValue(varBinding, 2);

View File

@ -0,0 +1,4 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
throw new TypeError();

View File

@ -0,0 +1,4 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
throw new Error();

View File

@ -0,0 +1,20 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Abrupt completion during module evaluation precludes further evaluation
esid: sec-moduleevaluation
info: |
[...]
6. For each String required that is an element of
module.[[RequestedModules]] do,
a. Let requiredModule be ? HostResolveImportedModule(module, required).
b. Perform ? requiredModule.ModuleEvaluation().
negative: TypeError
flags: [module]
---*/
import './eval-rqstd-abrupt-err-type_FIXTURE.js';
import './eval-rqstd-abrupt-err-uri_FIXTURE.js';
throw new RangeError();

View File

@ -0,0 +1,30 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Requested modules are evaluated exactly once
esid: sec-moduleevaluation
info: |
[...]
4. If module.[[Evaluated]] is true, return undefined.
5. Set module.[[Evaluated]] to true.
6. For each String required that is an element of module.[[RequestedModules]] do,
a. Let requiredModule be ? HostResolveImportedModule(module, required).
b. Perform ? requiredModule.ModuleEvaluation().
[...]
includes: [fnGlobalObject.js]
flags: [module]
---*/
import {} from './eval-rqstd-once_FIXTURE.js';
import './eval-rqstd-once_FIXTURE.js';
import * as ns1 from './eval-rqstd-once_FIXTURE.js';
import dflt1 from './eval-rqstd-once_FIXTURE.js';
export {} from './eval-rqstd-once_FIXTURE.js';
import dflt2, {} from './eval-rqstd-once_FIXTURE.js';
export * from './eval-rqstd-once_FIXTURE.js';
import dflt3, * as ns from './eval-rqstd-once_FIXTURE.js';
export default null;
var global = fnGlobalObject();
assert.sameValue(global.test262, 262, 'global property was defined');

View File

@ -0,0 +1,15 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
export default null;
var global = Function('return this;')();
if (global.test262) {
throw new Error('Module was evaluated more than once.');
}
global.test262 = 262;
if (global.test262 !== 262) {
throw new Error('Module was unable to signal evaluation.');
}

View File

@ -0,0 +1,4 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
Function('return this;')().test262 = '1';

View File

@ -0,0 +1,4 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
Function('return this;')().test262 += '2';

View File

@ -0,0 +1,4 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
Function('return this;')().test262 += '3';

View File

@ -0,0 +1,6 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
Function('return this;')().test262 += '4';
export default null;

View File

@ -0,0 +1,4 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
Function('return this;')().test262 += '5';

View File

@ -0,0 +1,6 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
Function('return this;')().test262 += '6';
export default null;

View File

@ -0,0 +1,4 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
Function('return this;')().test262 += '7';

View File

@ -0,0 +1,6 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
Function('return this;')().test262 += '8';
export default null;

View File

@ -0,0 +1,37 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Requested modules are evaluated prior to the requesting module in source
code order
esid: sec-moduleevaluation
info: |
[...]
6. For each String required that is an element of
module.[[RequestedModules]] do,
a. Let requiredModule be ? HostResolveImportedModule(module, required).
b. Perform ? requiredModule.ModuleEvaluation().
[...]
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
[...]
includes: [fnGlobalObject.js]
flags: [module]
---*/
assert.sameValue(fnGlobalObject().test262, '12345678');
import {} from './eval-rqstd-order-1_FIXTURE.js';
import './eval-rqstd-order-2_FIXTURE.js';
import * as ns1 from './eval-rqstd-order-3_FIXTURE.js';
import dflt1 from './eval-rqstd-order-4_FIXTURE.js';
export {} from './eval-rqstd-order-5_FIXTURE.js';
import dflt2, {} from './eval-rqstd-order-6_FIXTURE.js';
export * from './eval-rqstd-order-7_FIXTURE.js';
import dflt3, * as ns from './eval-rqstd-order-8_FIXTURE.js';

View File

@ -0,0 +1,17 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Abrupt completion from module evaluation is reported
esid: sec-moduleevaluation
info: |
[...]
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
17. Suspend moduleCxt and remove it from the execution context stack.
18. Resume the context that is now on the top of the execution context
stack as the running execution context.
19. Return Completion(result).
negative: Test262Error
flags: [module]
---*/
throw new Test262Error();

View File

@ -0,0 +1,34 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Module is evaluated exactly once
esid: sec-moduleevaluation
info: |
[...]
4. If module.[[Evaluated]] is true, return undefined.
5. Set module.[[Evaluated]] to true.
6. For each String required that is an element of module.[[RequestedModules]] do,
a. Let requiredModule be ? HostResolveImportedModule(module, required).
b. Perform ? requiredModule.ModuleEvaluation().
[...]
includes: [fnGlobalObject.js]
flags: [module]
---*/
import {} from './eval-self-once.js';
import './eval-self-once.js';
import * as ns1 from './eval-self-once.js';
import dflt1 from './eval-self-once.js';
export {} from './eval-self-once.js';
import dflt2, {} from './eval-self-once.js';
export * from './eval-self-once.js';
import dflt3, * as ns from './eval-self-once.js';
export default null;
var global = fnGlobalObject();
assert.sameValue(global.test262, undefined, 'global property initially unset');
global.test262 = 262;
assert.sameValue(global.test262, 262, 'global property was defined');

View File

@ -0,0 +1,45 @@
// 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 Environment Records provide a this binding, and the value is
`undefined`.
esid: sec-moduleevaluation
info: |
[...]
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
[...]
12.2.2 The this Keyword
12.2.2.1 Runtime Semantics: Evaluation
PrimaryExpression : this
1. Return ? ResolveThisBinding( ).
8.3.4 ResolveThisBinding ( )
1. Let envRec be GetThisEnvironment( ).
2. Return ? envRec.GetThisBinding().
8.3.3 GetThisEnvironment ( )
1. Let lex be the running execution context's LexicalEnvironment.
2. Repeat
a. Let envRec be lex's EnvironmentRecord.
b. Let exists be envRec.HasThisBinding().
c. If exists is true, return envRec.
d. Let outer be the value of lex's outer environment reference.
e. Let lex be outer.
8.1.1.5.3 HasThisBinding ()
1. Return true.
8.1.1.5.4 GetThisBinding ()
1. Return undefined.
flags: [module]
---*/
assert.sameValue(this, undefined);