summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/testMissingProperties.js
blob: 71512c6f5c7fb9b8025dc0100762e4ba01e73cbe (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function isnan(n) { return n !== n }

function f(x) {
    var sum = 0;
    for (var i = 0; i < 100; ++i)
        sum += x.x;
    return sum;
}
var o = {};
assertEq(isnan(f(o)), true);
o.x = 1;
assertEq(f(o), 100);
var o = {a:1, b:2};
assertEq(isnan(f(o)), true);
o.x = 2;
assertEq(f(o), 200);

function g(x) {
    var sum = 0;
    for (var i = 0; i < 100; ++i)
        sum += x.x;
    return sum;
}
var o = {c:1, x:1};
assertEq(g(o), 100);
var o = {};
assertEq(isnan(g(o)), true);

function h(x) {
    var sum = 0;
    for (var i = 0; i < 100; ++i)
        sum += x.x;
    return sum;
}

var proto1 = {};
var proto2 = Object.create(proto1);
var o = Object.create(proto2);
assertEq(isnan(f(o)), true);
assertEq(isnan(g(o)), true);
assertEq(isnan(h(o)), true);
proto2.x = 2;
assertEq(f(o), 200);
assertEq(g(o), 200);
assertEq(h(o), 200);
var o = {}
assertEq(isnan(f(o)), true);
assertEq(isnan(g(o)), true);
assertEq(isnan(h(o)), true);