]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/int32-out-of-bounds.js
JavaScriptCore-7600.1.4.16.1.tar.gz
[apple/javascriptcore.git] / tests / stress / int32-out-of-bounds.js
1 function foo(a, i) {
2 return a[i];
3 }
4
5 noInline(foo);
6
7 function test(value) {
8 var result = foo([value], 0);
9 if (result != value)
10 throw "Error: bad result: " + result;
11 }
12
13 for (var i = 0; i < 100000; ++i)
14 test(42);
15
16 var result = foo([42], 1);
17 if (result !== void 0)
18 throw "Error: bad result: " + result;
19
20 result = foo([42], 100);
21 if (result !== void 0)
22 throw "Error: bad result: " + result;
23
24 result = foo([42], 10000);
25 if (result !== void 0)
26 throw "Error: bad result: " + result;
27
28 Array.prototype[10000] = 23;
29 result = foo([42], 10000);
30 if (result !== 23)
31 throw "Error: bad result: " + result;