]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/tricky-array-bounds-checks.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / tricky-array-bounds-checks.js
1 function foo(a, i, p) {
2 if (p || !DFGTrue())
3 return [DFGTrue(), a[(i - (DFGTrue() ? 2147483646 : 0)) | 0], a[i], a[(i + (DFGTrue() ? 2147483646 : 0)) | 0], DFGTrue()];
4 return [12];
5 }
6
7 noInline(foo);
8
9 function arraycmp(a, b) {
10 if (a.length != b.length)
11 return false;
12 for (var i = 0; i < a.length; ++i) {
13 if (a[i] != b[i])
14 return false;
15 }
16 return true;
17 }
18
19 for (var i = 0; i < 100000; ++i) {
20 var result = foo([42], 0, false);
21 if (!arraycmp(result, [false, 42, 42, 42, false]) && !arraycmp(result, [12]))
22 throw "Error: bad result for i = " + i + ": " + result;
23 }
24
25 var result = foo([1, 2, 3, 4, 5], -2147483646, true);
26 if (!arraycmp(result, [true, 5, void 0, void 0, false])
27 && !arraycmp(result, [false, void 0, void 0, void 0, false]))
28 throw "Error: bad result for trick: " + result;