]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/fold-multi-get-by-offset-to-get-by-offset-without-folding-the-structure-check.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / fold-multi-get-by-offset-to-get-by-offset-without-folding-the-structure-check.js
1 function foo(o) {
2 return o.f;
3 }
4
5 function fu(o) {
6 return o.e;
7 }
8
9 function bar(f, o) {
10 return f(o);
11 }
12
13 function baz(f, o) {
14 return f(o);
15 }
16
17 for (var i = 0; i < 100; ++i) {
18 foo({f:1, e:2});
19 foo({e:1, f:2});
20 foo({d:1, e:2, f:3});
21 fu({f:1, e:2});
22 fu({e:1, f:2, g:3});
23 fu({d:1, e:2, f:3, g:4});
24 }
25
26 for (var i = 0; i < 100; ++i) {
27 bar(foo, {f:1});
28 bar(function() { }, null);
29 bar(function() { return 42; }, null);
30 baz(fu, {e:1});
31 baz(function() { }, null);
32 baz(function() { return 42; }, null);
33 }
34
35 (function(f, g, o, p) {
36 var result = 0;
37 var n = 1000000;
38 for (var i = 0; i < n; ++i) {
39 var q;
40 if (i == n - 1)
41 q = p;
42 else
43 q = o;
44 result += baz(g, q);
45 result += bar(f, q);
46 }
47 if (result != (n - 1) * (o.f + o.e) + 12 + 13)
48 throw "Error: bad result: " + result;
49 })(foo, fu, {f:42, e:2}, {e:12, f:13, g:14});
50