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