]> git.saurik.com Git - apple/javascriptcore.git/blame_incremental - tests/stress/new-contiguous-array-with-size.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / new-contiguous-array-with-size.js
... / ...
CommitLineData
1function foo(x) {
2 return new Array(x);
3}
4
5noInline(foo);
6
7function test(size) {
8 var result = foo(size);
9 if (result.length != size) {
10 print("Got a weird length: " + result.length);
11 throw "Error: bad result: " + result;
12 }
13 var sawThings = false;
14 for (var s in result)
15 sawThings = true;
16 if (sawThings) {
17 print("Saw things!");
18 throw "Error: array is in bad state: " + result;
19 }
20 result[0] = "42.5";
21 if (result[0] != "42.5") {
22 print("Didn't store what I thought I stored.");
23 throw "Error: array is in wierd state: " + result;
24 }
25}
26
27for (var i = 0; i < 100000; ++i) {
28 test(0);
29 test(1);
30 test(42);
31}