summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/cacheir/spread-minmax-2.js
blob: 4cc3b0d9d6c64afdf88cf75f55218d93135fc45a (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(...arr);
    }
    return sum;
}

function testMax(arr) {
    var sum = 0;
    for (var i = 0; i < 50; i++) {
	sum += Math.max(...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);