tor-browser

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

array-contract-expand.js (714B)


      1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: >
      6    Array entry removal and re-insertion during traversal using for..of
      7 info: |
      8    Entries removed from an Array instance during traversal should be visited
      9    if they are re-inserted prior to iterator exhaustion.
     10 es6id: 13.6.4
     11 ---*/
     12 
     13 var array = [0, 1];
     14 var iterationCount = 0;
     15 
     16 var first = 0;
     17 var second = 1;
     18 
     19 for (var x of array) {
     20  assert.sameValue(x, first);
     21 
     22  first = second;
     23  second = null;
     24 
     25  if (first !== null) {
     26    array.pop();
     27    array.push(1);
     28  }
     29 
     30  iterationCount += 1;
     31 }
     32 
     33 assert.sameValue(iterationCount, 2);
     34 
     35 reportCompare(0, 0);