summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/collections/Map-constructor-generator-1.js
blob: 61a319846cc123abc879f1293672723b3d47d178 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// The argument to Map can be a generator.

var done = false;
function data(n) {
    var s = '';
    for (var i = 0; i < n; i++) {
        yield [s, i];
        s += '.';
    }
    done = true;
}

var m = new Map(data(50));
assertEq(done, true);  // the constructor consumes the argument
assertEq(m.size, 50);
assertEq(m.get(""), 0);
assertEq(m.get("....."), 5);
assertEq(m.get(Array(49+1).join(".")), 49);
assertEq(m.has(undefined), false);