summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ion/inlining/inline-getelem-args.js
blob: 41acaf6a04ddd889f62a2d91c1d96b8c58ea32ee (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
50
51
52
53
54
55
56
57
58
59
function cat() {
    var res = "";
    for (var i = 0; i < arguments.length; i++)
        res += arguments[i];
    return res;
}

function cat_m1(ion) {
    var res = "";
    for (var i = (ion ? -1 : 0); i < arguments.length; i++)
        res += arguments[i];
    return res;
}

function cat_p1(ion) {
    var res = "";
    for (var i = 0; i < arguments.length + (ion ? 1 : 0); i++)
        res += arguments[i];
    return res;
}

function sum() {
    var res = 0;
    for (var i = 0; i < arguments.length; i++)
        res += arguments[i];
    return res;
}

function wrapper() {
    var res;
    var i6 = { valueOf: () => 6 },
        i8 = 8.5,
        s2 = { toString: () => "2" },
        s4 = {},
        s6 = "6",
        s7 = undefined,
        s8 = null;
    for (var b = true; b; b = !inIon()) {
        res = sum(1,2,3,4,5,i6,7,i8,9,10);
        assertEq(res, 55.5);

        res = cat(true,s2,3,s4,5,s6,s7,s8);
        assertEq(res, "true23[object Object]56undefinednull");

        ion = inIon();
        if (typeof ion !== "boolean") break;
        res = cat_m1(ion,1,s2,3,s4,5,s6,s7,s8);
        if (ion) assertEq(res, "undefinedtrue123[object Object]56undefinednull");
        else assertEq(res, "false123[object Object]56undefinednull");

        ion = inIon();
        if (typeof ion !== "boolean") break;
        res = cat_p1(ion,1,s2,3,s4,5,s6,s7,s8);
        if (ion) assertEq(res, "true123[object Object]56undefinednullundefined");
        else assertEq(res, "false123[object Object]56undefinednull");
    }
}

wrapper();