summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/collections/for-in.js
blob: b46de15e21668dafd91e90f3ee02b722cc127e41 (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
// for-in loops on Maps and Sets enumerate properties.

var test = function test(obj) {
    assertEq(Object.keys(obj).length, 0);

    var i = 0, v;
    for (v in obj)
        i++;
    assertEq(i, 0);

    obj.ownProp = 1;
    assertEq(Object.keys(obj).join(), "ownProp");

    for (v in obj)
        i++;
    assertEq(i, 1);
    assertEq(v, "ownProp");

    delete obj.ownProp;
};

test(Map.prototype);
test(new Map);
test(Set.prototype);
test(new Set);