tor-browser

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

source-object-iterator-2.js (938B)


      1 // Copyright 2015 Microsoft Corporation. All rights reserved.
      2 // This code is governed by the license found in the LICENSE file.
      3 
      4 /*---
      5 description: Source object has iterator
      6 esid: sec-array.from
      7 es6id: 22.1.2.1
      8 features: [Symbol.iterator]
      9 ---*/
     10 
     11 var array = [2, 4, 8, 16, 32, 64, 128];
     12 var obj = {
     13  [Symbol.iterator]() {
     14    return {
     15      index: 0,
     16      next() {
     17        return {
     18          value: this.val,
     19          done: this.isDone
     20        };
     21      },
     22      isDone: false,
     23      get val() {
     24        this.index++;
     25        if (this.index > 7) {
     26          this.isDone = true;
     27        }
     28        return 1 << this.index;
     29      }
     30    };
     31  }
     32 };
     33 var a = Array.from.call(Object, obj);
     34 assert.sameValue(typeof a, typeof {}, 'The value of `typeof a` is expected to be typeof {}');
     35 for (var j = 0; j < a.length; j++) {
     36  assert.sameValue(a[j], array[j], 'The value of a[j] is expected to equal the value of array[j]');
     37 }
     38 
     39 reportCompare(0, 0);