summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ion/math-max-arraylength.js
blob: dd8e915f84fc33992f72a9506d32520af74ddb80 (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
var arrays = [
    [],
    [1],
    [1, 2],
    [1, 2, 3],
    [1, 2, 3, 4],
];

function test() {
    for (var i = 0; i < arrays.length; i++) {
        var array = arrays[i];

        assertEq(Math.max(array.length, 0), i);
        assertEq(Math.max(0, array.length), i);

        assertEq(Math.max(array.length, -1), i);
        assertEq(Math.max(-1, array.length), i);

        assertEq(Math.max(array.length, -1.5), i);
        assertEq(Math.max(-1.5, array.length), i);
    }
}

test();
test();