summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/cacheir/spread-minmax-1.js
blob: b1bd6e5692c6982fc7e253698f08dc35e72fa70f (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 an empty list correctly.
assertEq(testMin([]), Infinity);
assertEq(testMax([]), -Infinity);