]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/tricky-array-bounds-checks.js
1 function foo(a
, i
, p
) {
3 return [DFGTrue(), a
[(i
- (DFGTrue() ? 2147483646 : 0)) | 0], a
[i
], a
[(i
+ (DFGTrue() ? 2147483646 : 0)) | 0], DFGTrue()];
9 function arraycmp(a
, b
) {
10 if (a
.length
!= b
.length
)
12 for (var i
= 0; i
< a
.length
; ++i
) {
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
;
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
;