summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/cacheir/apply-minmax-2.js
blob: 28ff6873295edb065ab04bb5a65ff00178806e6d (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 a double element correctly.
assertEq(testMin([1,2,3.5,4,5]), 50);
assertEq(testMax([1,2,3.5,4,5]), 250);