summaryrefslogtreecommitdiffstats
path: root/third_party/webkit/PerformanceTests/six-speed/tests/spread-generator.es5
blob: 2a0305b3490decc97cab28c1fb9f4c40c4cbb4fc (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
function generator() {
  var i = 0;
  return {
    next: function() {
      i++;
      if (i >= 4) {
        return {done: true};
      } else {
        return {
          value: i,
          done: false
        };
      }
    }
  };
}

function fn() {
  var iterator = generator();
  var args = [iterator.next().value, iterator.next().value, iterator.next().value];
  iterator.next();

  return Math.max.apply(Math, args);
}

assertEqual(fn(), 3);
test(fn);