]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/fold-multi-put-by-offset-to-put-by-offset-without-folding-the-structure-check.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / fold-multi-put-by-offset-to-put-by-offset-without-folding-the-structure-check.js
1 function foo(o) {
2 o.f = 1;
3 }
4
5 function fu(o) {
6 o.e = 2;
7 }
8
9 function bar(f, o) {
10 f(o);
11 }
12
13 function baz(f, o) {
14 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 baz(g, q);
45 bar(f, q);
46 }
47 if (o.e != 2)
48 throw "Error: bad value in o.e: " + o.e;
49 if (o.f != 1)
50 throw "Error: bad value in o.f: " + o.f;
51 if (p.e != 2)
52 throw "Error: bad value in p.e: " + p.e;
53 if (p.f != 1)
54 throw "Error: bad value in p.f: " + p.f;
55 })(foo, fu, {f:42, e:2}, {e:12, f:13, g:14});
56