tor-browser

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

cptn-decl-abrupt-empty.js (1429B)


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