]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/new-array-storage-array-with-size.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / new-array-storage-array-with-size.js
1 function foo(x) {
2 return new Array(x);
3 }
4
5 noInline(foo);
6
7 // Warm up up to create array storage.
8 for (var i = 0; i < 10000; ++i) {
9 var array = foo(10);
10 array.__defineSetter__(0, function(v) { });
11 }
12
13 function test(size) {
14 var result = foo(size);
15 if (result.length != size)
16 throw "Error: bad result: " + result;
17 var sawThings = false;
18 for (var s in result)
19 sawThings = true;
20 if (sawThings)
21 throw "Error: array is in bad state: " + result;
22 result[0] = "42.5";
23 if (result[0] != "42.5")
24 throw "Error: array is in wierd state: " + result;
25 }
26
27 for (var i = 0; i < 100000; ++i) {
28 test(10);
29 }