mirror of
https://github.com/tc39/test262.git
synced 2025-05-04 23:10:27 +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.
30 lines
1.0 KiB
JavaScript
30 lines
1.0 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-switch-statement-runtime-semantics-evaluation
|
|
description: Creation of new lexical environment (into `default` clause)
|
|
info: |
|
|
1. Let exprRef be the result of evaluating Expression.
|
|
2. Let switchValue be ? GetValue(exprRef).
|
|
3. Let oldEnv be the running execution context's LexicalEnvironment.
|
|
4. Let blockEnv be NewDeclarativeEnvironment(oldEnv).
|
|
5. Perform BlockDeclarationInstantiation(CaseBlock, blockEnv).
|
|
6. Set the running execution context's LexicalEnvironment to blockEnv.
|
|
7. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
|
argument switchValue.
|
|
[...]
|
|
features: [let]
|
|
---*/
|
|
|
|
let x = 'outside';
|
|
var probeExpr, probeStmt;
|
|
|
|
switch (probeExpr = function() { return x; }) {
|
|
default:
|
|
probeStmt = function() { return x; };
|
|
let x = 'inside';
|
|
}
|
|
|
|
assert.sameValue(probeExpr(), 'outside');
|
|
assert.sameValue(probeStmt(), 'inside');
|