diff --git a/test/language/module-code/eval-export-cls-semi.js b/test/language/module-code/eval-export-cls-semi.js new file mode 100644 index 0000000000..d9a4dc1b4c --- /dev/null +++ b/test/language/module-code/eval-export-cls-semi.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +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); diff --git a/test/language/module-code/eval-export-dflt-cls-anon-semi.js b/test/language/module-code/eval-export-dflt-cls-anon-semi.js new file mode 100644 index 0000000000..f0fee9b9eb --- /dev/null +++ b/test/language/module-code/eval-export-dflt-cls-anon-semi.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +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); diff --git a/test/language/module-code/eval-export-dflt-cls-anon.js b/test/language/module-code/eval-export-dflt-cls-anon.js new file mode 100644 index 0000000000..07c5cce40f --- /dev/null +++ b/test/language/module-code/eval-export-dflt-cls-anon.js @@ -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'); diff --git a/test/language/module-code/eval-export-dflt-cls-name-meth.js b/test/language/module-code/eval-export-dflt-cls-name-meth.js new file mode 100644 index 0000000000..8aa59e7782 --- /dev/null +++ b/test/language/module-code/eval-export-dflt-cls-name-meth.js @@ -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' +); diff --git a/test/language/module-code/eval-export-dflt-cls-named-semi.js b/test/language/module-code/eval-export-dflt-cls-named-semi.js new file mode 100644 index 0000000000..412d53270a --- /dev/null +++ b/test/language/module-code/eval-export-dflt-cls-named-semi.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +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); diff --git a/test/language/module-code/eval-export-dflt-cls-named.js b/test/language/module-code/eval-export-dflt-cls-named.js new file mode 100644 index 0000000000..cbba7e4cf6 --- /dev/null +++ b/test/language/module-code/eval-export-dflt-cls-named.js @@ -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'); diff --git a/test/language/module-code/eval-export-dflt-expr-cls-anon.js b/test/language/module-code/eval-export-dflt-expr-cls-anon.js new file mode 100644 index 0000000000..4faf148287 --- /dev/null +++ b/test/language/module-code/eval-export-dflt-expr-cls-anon.js @@ -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'); diff --git a/test/language/module-code/eval-export-dflt-expr-cls-name-meth.js b/test/language/module-code/eval-export-dflt-expr-cls-name-meth.js new file mode 100644 index 0000000000..bc6e1b1e10 --- /dev/null +++ b/test/language/module-code/eval-export-dflt-expr-cls-name-meth.js @@ -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' +); diff --git a/test/language/module-code/eval-export-dflt-expr-cls-named.js b/test/language/module-code/eval-export-dflt-expr-cls-named.js new file mode 100644 index 0000000000..f5900a09ad --- /dev/null +++ b/test/language/module-code/eval-export-dflt-expr-cls-named.js @@ -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'); diff --git a/test/language/module-code/eval-export-dflt-expr-err-eval.js b/test/language/module-code/eval-export-dflt-expr-err-eval.js new file mode 100644 index 0000000000..5e8c31ed58 --- /dev/null +++ b/test/language/module-code/eval-export-dflt-expr-err-eval.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + 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(); })(); diff --git a/test/language/module-code/eval-export-dflt-expr-err-get-value.js b/test/language/module-code/eval-export-dflt-expr-err-get-value.js new file mode 100644 index 0000000000..8d292118e3 --- /dev/null +++ b/test/language/module-code/eval-export-dflt-expr-err-get-value.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + 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; diff --git a/test/language/module-code/eval-export-dflt-expr-fn-anon.js b/test/language/module-code/eval-export-dflt-expr-fn-anon.js new file mode 100644 index 0000000000..748d104327 --- /dev/null +++ b/test/language/module-code/eval-export-dflt-expr-fn-anon.js @@ -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'); diff --git a/test/language/module-code/eval-export-dflt-expr-fn-named.js b/test/language/module-code/eval-export-dflt-expr-fn-named.js new file mode 100644 index 0000000000..7e5fb6b581 --- /dev/null +++ b/test/language/module-code/eval-export-dflt-expr-fn-named.js @@ -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'); diff --git a/test/language/module-code/eval-export-dflt-expr-gen-anon.js b/test/language/module-code/eval-export-dflt-expr-gen-anon.js new file mode 100644 index 0000000000..5b458012e2 --- /dev/null +++ b/test/language/module-code/eval-export-dflt-expr-gen-anon.js @@ -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'); diff --git a/test/language/module-code/eval-export-dflt-expr-gen-named.js b/test/language/module-code/eval-export-dflt-expr-gen-named.js new file mode 100644 index 0000000000..16fb4bc910 --- /dev/null +++ b/test/language/module-code/eval-export-dflt-expr-gen-named.js @@ -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'); diff --git a/test/language/module-code/eval-export-dflt-expr-in.js b/test/language/module-code/eval-export-dflt-expr-in.js new file mode 100644 index 0000000000..5a99b3bc2a --- /dev/null +++ b/test/language/module-code/eval-export-dflt-expr-in.js @@ -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); diff --git a/test/language/module-code/eval-export-dflt-fun-anon-semi.js b/test/language/module-code/eval-export-dflt-fun-anon-semi.js new file mode 100644 index 0000000000..b26fdfbe87 --- /dev/null +++ b/test/language/module-code/eval-export-dflt-fun-anon-semi.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +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); diff --git a/test/language/module-code/eval-export-dflt-fun-named-semi.js b/test/language/module-code/eval-export-dflt-fun-named-semi.js new file mode 100644 index 0000000000..652b1cc76f --- /dev/null +++ b/test/language/module-code/eval-export-dflt-fun-named-semi.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +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); diff --git a/test/language/module-code/eval-export-dflt-gen-anon-semi.js b/test/language/module-code/eval-export-dflt-gen-anon-semi.js new file mode 100644 index 0000000000..f5fb576bf9 --- /dev/null +++ b/test/language/module-code/eval-export-dflt-gen-anon-semi.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +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); diff --git a/test/language/module-code/eval-export-dflt-gen-named-semi.js b/test/language/module-code/eval-export-dflt-gen-named-semi.js new file mode 100644 index 0000000000..deff1436ed --- /dev/null +++ b/test/language/module-code/eval-export-dflt-gen-named-semi.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +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); diff --git a/test/language/module-code/eval-export-fun-semi.js b/test/language/module-code/eval-export-fun-semi.js new file mode 100644 index 0000000000..a4e49ea7cd --- /dev/null +++ b/test/language/module-code/eval-export-fun-semi.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +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); diff --git a/test/language/module-code/eval-export-gen-semi.js b/test/language/module-code/eval-export-gen-semi.js new file mode 100644 index 0000000000..0152b14412 --- /dev/null +++ b/test/language/module-code/eval-export-gen-semi.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +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); diff --git a/test/language/module-code/eval-gtbndng-indirect-trlng-comma.js b/test/language/module-code/eval-gtbndng-indirect-trlng-comma.js new file mode 100644 index 0000000000..3bff206700 --- /dev/null +++ b/test/language/module-code/eval-gtbndng-indirect-trlng-comma.js @@ -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); diff --git a/test/language/module-code/eval-gtbndng-indirect-trlng-comma_FIXTURE.js b/test/language/module-code/eval-gtbndng-indirect-trlng-comma_FIXTURE.js new file mode 100644 index 0000000000..e45b5b21cc --- /dev/null +++ b/test/language/module-code/eval-gtbndng-indirect-trlng-comma_FIXTURE.js @@ -0,0 +1,4 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export var x = 1; diff --git a/test/language/module-code/eval-gtbndng-indirect-update-as.js b/test/language/module-code/eval-gtbndng-indirect-update-as.js new file mode 100644 index 0000000000..cbe8afceff --- /dev/null +++ b/test/language/module-code/eval-gtbndng-indirect-update-as.js @@ -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); diff --git a/test/language/module-code/eval-gtbndng-indirect-update-as_FIXTURE.js b/test/language/module-code/eval-gtbndng-indirect-update-as_FIXTURE.js new file mode 100644 index 0000000000..bd505a0210 --- /dev/null +++ b/test/language/module-code/eval-gtbndng-indirect-update-as_FIXTURE.js @@ -0,0 +1,9 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +var x = 1; +export { x }; + +Function('return this;')().test262update = function() { + x = 2; +}; diff --git a/test/language/module-code/eval-gtbndng-indirect-update-dflt.js b/test/language/module-code/eval-gtbndng-indirect-update-dflt.js new file mode 100644 index 0000000000..d5ffcf57f1 --- /dev/null +++ b/test/language/module-code/eval-gtbndng-indirect-update-dflt.js @@ -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); diff --git a/test/language/module-code/eval-gtbndng-indirect-update-dflt_FIXTURE.js b/test/language/module-code/eval-gtbndng-indirect-update-dflt_FIXTURE.js new file mode 100644 index 0000000000..61b27a569e --- /dev/null +++ b/test/language/module-code/eval-gtbndng-indirect-update-dflt_FIXTURE.js @@ -0,0 +1,7 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export default function fn() { + fn = 2; + return 1; +} diff --git a/test/language/module-code/eval-gtbndng-indirect-update.js b/test/language/module-code/eval-gtbndng-indirect-update.js new file mode 100644 index 0000000000..14cdab3160 --- /dev/null +++ b/test/language/module-code/eval-gtbndng-indirect-update.js @@ -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); diff --git a/test/language/module-code/eval-gtbndng-indirect-update_FIXTURE.js b/test/language/module-code/eval-gtbndng-indirect-update_FIXTURE.js new file mode 100644 index 0000000000..bd505a0210 --- /dev/null +++ b/test/language/module-code/eval-gtbndng-indirect-update_FIXTURE.js @@ -0,0 +1,9 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +var x = 1; +export { x }; + +Function('return this;')().test262update = function() { + x = 2; +}; diff --git a/test/language/module-code/eval-gtbndng-local-bndng-cls.js b/test/language/module-code/eval-gtbndng-local-bndng-cls.js new file mode 100644 index 0000000000..254800664a --- /dev/null +++ b/test/language/module-code/eval-gtbndng-local-bndng-cls.js @@ -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); diff --git a/test/language/module-code/eval-gtbndng-local-bndng-const.js b/test/language/module-code/eval-gtbndng-local-bndng-const.js new file mode 100644 index 0000000000..51529d2682 --- /dev/null +++ b/test/language/module-code/eval-gtbndng-local-bndng-const.js @@ -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); diff --git a/test/language/module-code/eval-gtbndng-local-bndng-let.js b/test/language/module-code/eval-gtbndng-local-bndng-let.js new file mode 100644 index 0000000000..0ded885490 --- /dev/null +++ b/test/language/module-code/eval-gtbndng-local-bndng-let.js @@ -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); diff --git a/test/language/module-code/eval-gtbndng-local-bndng-var.js b/test/language/module-code/eval-gtbndng-local-bndng-var.js new file mode 100644 index 0000000000..6deafbcc2a --- /dev/null +++ b/test/language/module-code/eval-gtbndng-local-bndng-var.js @@ -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); diff --git a/test/language/module-code/eval-rqstd-abrupt-err-type_FIXTURE.js b/test/language/module-code/eval-rqstd-abrupt-err-type_FIXTURE.js new file mode 100644 index 0000000000..13544ca36a --- /dev/null +++ b/test/language/module-code/eval-rqstd-abrupt-err-type_FIXTURE.js @@ -0,0 +1,4 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +throw new TypeError(); diff --git a/test/language/module-code/eval-rqstd-abrupt-err-uri_FIXTURE.js b/test/language/module-code/eval-rqstd-abrupt-err-uri_FIXTURE.js new file mode 100644 index 0000000000..e9df60c255 --- /dev/null +++ b/test/language/module-code/eval-rqstd-abrupt-err-uri_FIXTURE.js @@ -0,0 +1,4 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +throw new Error(); diff --git a/test/language/module-code/eval-rqstd-abrupt.js b/test/language/module-code/eval-rqstd-abrupt.js new file mode 100644 index 0000000000..b52242627f --- /dev/null +++ b/test/language/module-code/eval-rqstd-abrupt.js @@ -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(); diff --git a/test/language/module-code/eval-rqstd-once.js b/test/language/module-code/eval-rqstd-once.js new file mode 100644 index 0000000000..93a3779be8 --- /dev/null +++ b/test/language/module-code/eval-rqstd-once.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: 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'); diff --git a/test/language/module-code/eval-rqstd-once_FIXTURE.js b/test/language/module-code/eval-rqstd-once_FIXTURE.js new file mode 100644 index 0000000000..8af3363daf --- /dev/null +++ b/test/language/module-code/eval-rqstd-once_FIXTURE.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export default null; +var global = Function('return this;')(); + +if (global.test262) { + throw new Error('Module was evaluated more than once.'); +} + +global.test262 = 262; + +if (global.test262 !== 262) { + throw new Error('Module was unable to signal evaluation.'); +} diff --git a/test/language/module-code/eval-rqstd-order-1_FIXTURE.js b/test/language/module-code/eval-rqstd-order-1_FIXTURE.js new file mode 100644 index 0000000000..c5d9a1f498 --- /dev/null +++ b/test/language/module-code/eval-rqstd-order-1_FIXTURE.js @@ -0,0 +1,4 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +Function('return this;')().test262 = '1'; diff --git a/test/language/module-code/eval-rqstd-order-2_FIXTURE.js b/test/language/module-code/eval-rqstd-order-2_FIXTURE.js new file mode 100644 index 0000000000..58552191b4 --- /dev/null +++ b/test/language/module-code/eval-rqstd-order-2_FIXTURE.js @@ -0,0 +1,4 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +Function('return this;')().test262 += '2'; diff --git a/test/language/module-code/eval-rqstd-order-3_FIXTURE.js b/test/language/module-code/eval-rqstd-order-3_FIXTURE.js new file mode 100644 index 0000000000..b3c83e25ab --- /dev/null +++ b/test/language/module-code/eval-rqstd-order-3_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. + +Function('return this;')().test262 += '3'; diff --git a/test/language/module-code/eval-rqstd-order-4_FIXTURE.js b/test/language/module-code/eval-rqstd-order-4_FIXTURE.js new file mode 100644 index 0000000000..e728d4e101 --- /dev/null +++ b/test/language/module-code/eval-rqstd-order-4_FIXTURE.js @@ -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; diff --git a/test/language/module-code/eval-rqstd-order-5_FIXTURE.js b/test/language/module-code/eval-rqstd-order-5_FIXTURE.js new file mode 100644 index 0000000000..04eb22ba54 --- /dev/null +++ b/test/language/module-code/eval-rqstd-order-5_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. + +Function('return this;')().test262 += '5'; diff --git a/test/language/module-code/eval-rqstd-order-6_FIXTURE.js b/test/language/module-code/eval-rqstd-order-6_FIXTURE.js new file mode 100644 index 0000000000..89b7a4b74b --- /dev/null +++ b/test/language/module-code/eval-rqstd-order-6_FIXTURE.js @@ -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; diff --git a/test/language/module-code/eval-rqstd-order-7_FIXTURE.js b/test/language/module-code/eval-rqstd-order-7_FIXTURE.js new file mode 100644 index 0000000000..3485babc3b --- /dev/null +++ b/test/language/module-code/eval-rqstd-order-7_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. + +Function('return this;')().test262 += '7'; diff --git a/test/language/module-code/eval-rqstd-order-8_FIXTURE.js b/test/language/module-code/eval-rqstd-order-8_FIXTURE.js new file mode 100644 index 0000000000..8512224663 --- /dev/null +++ b/test/language/module-code/eval-rqstd-order-8_FIXTURE.js @@ -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; diff --git a/test/language/module-code/eval-rqstd-order.js b/test/language/module-code/eval-rqstd-order.js new file mode 100644 index 0000000000..3d8ca0fdbd --- /dev/null +++ b/test/language/module-code/eval-rqstd-order.js @@ -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'; diff --git a/test/language/module-code/eval-self-abrupt.js b/test/language/module-code/eval-self-abrupt.js new file mode 100644 index 0000000000..bb23cb268c --- /dev/null +++ b/test/language/module-code/eval-self-abrupt.js @@ -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(); diff --git a/test/language/module-code/eval-self-once.js b/test/language/module-code/eval-self-once.js new file mode 100644 index 0000000000..1da75ae6c0 --- /dev/null +++ b/test/language/module-code/eval-self-once.js @@ -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'); diff --git a/test/language/module-code/eval-this.js b/test/language/module-code/eval-this.js new file mode 100644 index 0000000000..ce2af4000a --- /dev/null +++ b/test/language/module-code/eval-this.js @@ -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);