]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/redundant-array-bounds-checks.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / redundant-array-bounds-checks.js
1 function foo(a) {
2 return [a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7]];
3 }
4
5 noInline(foo);
6
7 function arraycmp(a, b) {
8 if (a.length != b.length)
9 return false;
10 for (var i = 0; i < a.length; ++i) {
11 if (a[i] != b[i])
12 return false;
13 }
14 return true;
15 }
16
17 for (var i = 0; i < 100000; ++i) {
18 var result = foo([1, 2, 3, 4, 5, 6, 7, 8]);
19 if (!arraycmp(result, [1, 2, 3, 4, 5, 6, 7, 8]))
20 throw "Error: bad result (1..8): " + result;
21 }
22
23 var result = foo([1, 2, 3, 4, 5, 6, 7]);
24 if (!arraycmp(result, [1, 2, 3, 4, 5, 6, 7, void 0]))
25 throw "Error: bad result (1..7): " + result;
26 var result = foo([1, 2, 3, 4, 5, 6]);
27 if (!arraycmp(result, [1, 2, 3, 4, 5, 6, void 0, void 0]))
28 throw "Error: bad result (1..6): " + result;
29 var result = foo([1, 2, 3, 4, 5]);
30 if (!arraycmp(result, [1, 2, 3, 4, 5, void 0, void 0, void 0]))
31 throw "Error: bad result (1..5): " + result;
32 var result = foo([1, 2, 3, 4]);
33 if (!arraycmp(result, [1, 2, 3, 4, void 0, void 0, void 0, void 0]))
34 throw "Error: bad result (1..4): " + result;
35 var result = foo([1, 2, 3]);
36 if (!arraycmp(result, [1, 2, 3, void 0, void 0, void 0, void 0, void 0]))
37 throw "Error: bad result (1..3): " + result;
38 var result = foo([1, 2]);
39 if (!arraycmp(result, [1, 2, void 0, void 0, void 0, void 0, void 0, void 0]))
40 throw "Error: bad result (1..2): " + result;
41 var result = foo([1]);
42 if (!arraycmp(result, [1, void 0, void 0, void 0, void 0, void 0, void 0, void 0]))
43 throw "Error: bad result (1..1): " + result;
44 var result = foo([]);
45 if (!arraycmp(result, [void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0]))
46 throw "Error: bad result (1..1): " + result;