tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

scope-head-lex-open.js (1628B)


      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: Creation of new lexical environment for the statement "head"
      6 info: |
      7    [...]
      8    2. Let loopEnv be NewDeclarativeEnvironment(oldEnv).
      9    3. Let loopEnvRec be loopEnv's EnvironmentRecord.
     10    4. Let isConst be the result of performing IsConstantDeclaration of
     11       LexicalDeclaration.
     12    5. Let boundNames be the BoundNames of LexicalDeclaration.
     13    6. For each element dn of boundNames do
     14       a. If isConst is true, then
     15          i. Perform ! loopEnvRec.CreateImmutableBinding(dn, true).
     16       b. Else,
     17          i. Perform ! loopEnvRec.CreateMutableBinding(dn, false).
     18    7. Set the running execution context's LexicalEnvironment to loopEnv.
     19    [...]
     20 features: [let]
     21 ---*/
     22 
     23 let x = 'outside';
     24 var probeBefore = function() { return x; };
     25 var probeDecl, probeTest, probeIncr, probeBody;
     26 var run = true;
     27 
     28 for (
     29    let x = 'inside', _ = probeDecl = function() { return x; };
     30    run && (probeTest = function() { return x; });
     31    probeIncr = function() { return x; }
     32  )
     33  probeBody = function() { return x; }, run = false;
     34 
     35 assert.sameValue(probeBefore(), 'outside');
     36 assert.sameValue(probeDecl(), 'inside', 'reference from LexicalDeclaration');
     37 assert.sameValue(probeTest(), 'inside', 'reference from "test" position');
     38 assert.sameValue(probeBody(), 'inside', 'reference from statement body');
     39 assert.sameValue(probeIncr(), 'inside', 'reference from "increment" position');
     40 
     41 reportCompare(0, 0);