tor-browser

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

set-contract-expand.js (742B)


      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: Set entry removal and re-insertion during traversal using for..of
      6 info: |
      7    Entries removed from a Set instance during traversal should be visited if
      8    they are re-inserted prior to iterator exhaustion.
      9 es6id: 13.6.4
     10 features: [Set]
     11 ---*/
     12 
     13 var set = new Set();
     14 var iterationCount = 0;
     15 
     16 var first = 0;
     17 var second = 1;
     18 
     19 set.add(0);
     20 set.add(1);
     21 
     22 for (var x of set) {
     23  assert.sameValue(x, first);
     24 
     25  first = second;
     26  second = null;
     27 
     28  if (first !== null) {
     29    set.delete(1);
     30    set.add(1);
     31  }
     32 
     33  iterationCount += 1;
     34 }
     35 
     36 assert.sameValue(iterationCount, 2);
     37 
     38 reportCompare(0, 0);