summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/cacheir/apply-minmax-1.js
blob: 3fbf48aba08ff46a9c5c7a97f0b6b5fdcb4a5f0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function testMin(arr) {
    var sum = 0;
    for (var i = 0; i < 50; i++) {
        sum += Math.min.apply(null, arr);
    }
    return sum;
}

function testMax(arr) {
    var sum = 0;
    for (var i = 0; i < 50; i++) {
        sum += Math.max.apply(null, arr);
    }
    return sum;
}

// Attach Int32MinMaxArrayResult.
assertEq(testMin([1,2,3,4,5]), 50);
assertEq(testMax([1,2,3,4,5]), 250);

// Verify that we handle an empty list correctly.
assertEq(testMin([]), Infinity);
assertEq(testMax([]), -Infinity);