tor-browser

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

cptn-expr-abrupt-empty.js (1500B)


      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 es6id: 13.7.5.11
      5 description: >
      6    Completion value when head has no declaration and iteration is cancelled
      7 info: |
      8    IterationStatement :
      9        for ( LeftHandSideExpression of AssignmentExpression ) Statement
     10 
     11    1. Let keyResult be the result of performing ForIn/OfHeadEvaluation( « »,
     12       AssignmentExpression, iterate).
     13    2. ReturnIfAbrupt(keyResult).
     14    3. Return ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
     15       keyResult, assignment, labelSet).
     16 
     17    13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
     18 
     19    [...]
     20    2. Let V = undefined.
     21    [...]
     22    5. Repeat
     23       a. Let nextResult be IteratorStep(iterator).
     24       b. ReturnIfAbrupt(nextResult).
     25       c. If nextResult is false, return NormalCompletion(V).
     26       [...]
     27       k. Let result be the result of evaluating stmt.
     28       [...]
     29       m. If LoopContinues(result, labelSet) is false, return
     30          IteratorClose(iterator, UpdateEmpty(result, V)).
     31 ---*/
     32 
     33 assert.sameValue(eval('var a; 1; for (a of [0]) { break; }'), undefined);
     34 assert.sameValue(eval('var b; 2; for (b of [0]) { 3; break; }'), 3);
     35 
     36 assert.sameValue(
     37  eval('var a; 4; outer: do { for (a of [0]) { continue outer; } } while (false)'),
     38  undefined
     39 );
     40 assert.sameValue(
     41  eval('var b; 5; outer: do { for (b of [0]) { 6; continue outer; } } while (false)'),
     42  6
     43 );
     44 
     45 reportCompare(0, 0);