tor-browser

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

generic-iterable.js (624B)


      1 // Copyright (C) 2013 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.6.4.13
      5 description: >
      6    Generic objects with `@@iterator` protocols should function as iterables.
      7 features: [Symbol.iterator]
      8 ---*/
      9 
     10 var iterable = {};
     11 iterable[Symbol.iterator] = function() {
     12  var j = 0;
     13  return {
     14    next: function() {
     15      j = j + 2;
     16      return { value: j, done: j === 8 };
     17    }
     18  }
     19 };
     20 var expected = [2, 4, 6];
     21 var i = 0;
     22 
     23 for (var x of iterable) {
     24  assert.sameValue(x, expected[i]);
     25  i++;
     26 }
     27 
     28 assert.sameValue(i, 3);
     29 
     30 reportCompare(0, 0);