mirror of
https://github.com/tc39/test262.git
synced 2025-05-04 15:00:42 +02:00
Add tests that assert the management of the running execution context's LexicalEnvironment and VariableEnvironment components, as created by the following abstract operations: - NewDeclarativeEnvironment - NewObjectEnvironment - NewFunctionEnvironment Many tests require the use of non-strict direct eval, meaning they may not be run in strict mode. This does not effect coverage because the semantics in these cases are not observable from strict mode code. Some situations require the creation of a binding, but this binding has no relevance to the test itself. In these cases, use names consisting solely of the underscore character (`_`). Avoid the use of Block statements wherever possible, as these trigger the creation of additional environments which may interfere with the behavior under test.
33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
/*---
|
|
esid: sec-function-definitions-runtime-semantics-iteratorbindinginitialization
|
|
description: >
|
|
Removal of variable environment for each BindingElement formal parameter
|
|
info: |
|
|
[...]
|
|
6. Let paramVarEnv be NewDeclarativeEnvironment(originalEnv).
|
|
7. Set the VariableEnvironment of currentContext to paramVarEnv.
|
|
8. Set the LexicalEnvironment of currentContext to paramVarEnv.
|
|
9. Let result be the result of performing IteratorBindingInitialization for
|
|
BindingElement using iteratorRecord and environment as the arguments.
|
|
10. Set the VariableEnvironment of currentContext to originalEnv.
|
|
11. Set the LexicalEnvironment of currentContext to originalEnv.
|
|
[...]
|
|
flags: [noStrict]
|
|
---*/
|
|
|
|
var x = 'outside';
|
|
var probe1, probe2, probeBody;
|
|
|
|
(function(
|
|
_ = (eval('var x = "inside";'), probe1 = function() { return x; }),
|
|
__ = probe2 = function() { return x; }
|
|
) {
|
|
probeBody = function() { return x; };
|
|
}());
|
|
|
|
assert.sameValue(probe1(), 'inside');
|
|
assert.sameValue(probe2(), 'outside');
|
|
assert.sameValue(probeBody(), 'outside');
|