summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Tuple/from/iter-map-fn-this-arg.js
blob: 2fdd3ddfb4126bb3737eac4dc2e59b91a577dbb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// |reftest| skip-if(!this.hasOwnProperty("Tuple"))

var thisVals = [];
var nextResult = {
  done: false,
  value: {}
};
var nextNextResult = {
  done: false,
  value: {}
};
var mapFn = function() {
  thisVals.push(this);
};
var items = {};
var thisVal = {};

items[Symbol.iterator] = function() {
  return {
    next: function() {
      var result = nextResult;
      nextResult = nextNextResult;
      nextNextResult = {
        done: true
      };

      return result;
    }
  };
};

Tuple.from(items, mapFn, thisVal);

assertEq(thisVals.length, 2);
assertEq(thisVals[0], thisVal);
assertEq(thisVals[1], thisVal);

reportCompare(0, 0);