summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/testFoldPropertyAccess.js
blob: 2ccb5e21f7ccec90159962b0c004cbeb9540f1cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

var cases = [
    function (obj) {
        return obj["ab"];
    },
    function (obj) {
        return obj["a" + "b"];
    },
    function (obj) {
        return obj[0 ? "cd" : "ab"];
    },
    function (obj) {
        return obj[true ? "ab" : "cd"];
    },
    function (obj) {
        return obj[(1 + 0) ? "ab" : "cd"];
    }
]

for (var i = 0; i < cases.length; i++) {
    assertEq(cases[i]({ab: 42}), 42);
    assertEq(cases[i]({cd: 120}), undefined);
}