Debian Codegraph @

js/src/tests/test262/language/statements/for/scope-body-lex-open.js

raw
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-for-statement-runtime-semantics-labelledevaluation
5 description: >
6 Creation of new lexical environment for the initial evaluation of the
7 statement body
8 info: |
9 [...]
10 11. Let bodyResult be ForBodyEvaluation(the first Expression, the second
11 Expression, Statement, perIterationLets, labelSet).
12 [...]
13
14 13.7.4.8 Runtime Semantics: ForBodyEvaluation
15
16 [...]
17 2. Perform ? CreatePerIterationEnvironment(perIterationBindings).
18 3. Repeat
19 [...]
20 b. Let result be the result of evaluating stmt.
21 [...]
22 [...]
23
24 13.7.4.9 Runtime Semantics: CreatePerIterationEnvironment
25
26 1. If perIterationBindings has any elements, then
27 [...]
28 e. Let thisIterationEnv be NewDeclarativeEnvironment(outer).
29 f. Let thisIterationEnvRec be thisIterationEnv's EnvironmentRecord.
30 features: [let]
31 ---*/
32
33 var probeBefore, probeTest, probeIncr, probeBody;
34 var run = true;
35
36 for (
37 let x = 'outside', _ = probeBefore = function() { return x; };
38 run && (x = 'inside', probeTest = function() { return x; });
39 probeIncr = function() { return x; }
40 )
41 probeBody = function() { return x; }, run = false;
42
43 assert.sameValue(probeBefore(), 'outside');
44 assert.sameValue(probeTest(), 'inside', 'reference from "test" position');
45 assert.sameValue(probeBody(), 'inside', 'reference from statement body');
46 assert.sameValue(probeIncr(), 'inside', 'reference from "increment" position');
47
48 reportCompare(0, 0);