summaryrefslogtreecommitdiffstats
path: root/js/src/tests/js1_7/geniter/yield-new.js
blob: 726da3944c9ba7cf9d6ea68b1e1c4055758472fb (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
const K = 20;

var obj;

var g = new function() {
    this.x = "puppies";
    obj = this;
    for (var i = 0; i < K; ++i)
        yield i;
    yield this;
}

var ct = 0;
for (var i in g)
    assertEq((ct < K && ct++ == i) || i == obj, true);
assertEq(i.x, "puppies");

function g2() {
    for (var i=0; i<20; i++)
	yield i;
}
var i = 0;
for (var x of new g2()) {
    assertEq(i, x);
    i++;
}

reportCompare(true,true);