summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/watchtower/megamorphic-has-prop.js
blob: 98481c636e597c220d06b96e61b620291a2133c5 (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
function hasOwnProp(o, p) {
    return Object.prototype.hasOwnProperty.call(o, p);
}
function testHasProp() {
    var C = Object.create(null);
    C.protox = 0;
    var B = Object.create(C);
    var objs = [];
    for (var i = 0; i < 50; i++) {
        var A = Object.create(B);
        A["x" + i] = 0;
        A.ownx = 3;
        objs.push(A);
    }
    for (var i = 0; i < 10; i++) {
        for (var j = 0; j < objs.length; j++) {
            var obj = objs[j];
            assertEq(hasOwnProp(obj, "protox"), false);
            assertEq("protox" in obj, true);
            assertEq(obj.protox, 0);

            assertEq(hasOwnProp(obj, "ownx"), true);
            assertEq("ownx" in obj, true);
            assertEq(obj.ownx, 3);

            assertEq("missing" in obj, false);
            assertEq(hasOwnProp(obj, "missing"), false);
            assertEq(obj.missing, undefined);
        }
    }
}
testHasProp();