]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/obviously-elidable-new-object-then-exit.js
faa5449cebb3c5718f7131bd7dfb80162c17d5f7
[apple/javascriptcore.git] / tests / stress / obviously-elidable-new-object-then-exit.js
1 function sumOfArithSeries(limit) {
2 return limit * (limit + 1) / 2;
3 }
4
5 var n = 10000000;
6
7 var array = [1, "hello"];
8
9 function foo() {
10 var result = 0;
11 var q;
12 for (var i = 0; i < n; ++i) {
13 var o = {f: i};
14 var p = {f: i + 1};
15 q = array[(i >= n - 100) | 0] + 1;
16 result += o.f + p.f;
17 }
18 return q + result;
19 }
20
21 var result = foo();
22 if (result != "hello" + 1 + (sumOfArithSeries(n - 1) + sumOfArithSeries(n)))
23 throw "Error: bad result: " + result;