]>
Commit | Line | Data |
---|---|---|
1 | function foo(a, b) { | |
2 | var array = []; | |
3 | for (var i = 0; i < arguments.length; ++i) | |
4 | array.push(arguments[i]); | |
5 | return {a:a, b:b, c:array}; | |
6 | } | |
7 | ||
8 | function bar(array) { | |
9 | return foo.apply(this, array); | |
10 | } | |
11 | ||
12 | function baz(array) { | |
13 | return bar(array); | |
14 | } | |
15 | ||
16 | noInline(baz); | |
17 | ||
18 | function checkEqual(a, b) { | |
19 | if (a.a != b.a) | |
20 | throw "Error: bad value of a: " + a.a + " versus " + b.a; | |
21 | if (a.b != b.b) | |
22 | throw "Error: bad value of b: " + a.b + " versus " + b.b; | |
23 | if (a.c.length != b.c.length) | |
24 | throw "Error: bad value of c, length mismatch: " + a.c + " versus " + b.c; | |
25 | for (var i = a.c.length; i--;) { | |
26 | if (a.c[i] != b.c[i]) | |
27 | throw "Error: bad value of c, mismatch at i = " + i + ": " + a.c + " versus " + b.c; | |
28 | } | |
29 | } | |
30 | ||
31 | function test(array) { | |
32 | var expected = {a:array[0], b:array[1], c:array}; | |
33 | var actual = baz(array); | |
34 | checkEqual(actual, expected); | |
35 | } | |
36 | ||
37 | for (var i = 0; i < 10000; ++i) { | |
38 | var array = []; | |
39 | for (var j = 0; j < i % 6; ++j) | |
40 | array.push(j); | |
41 | test(array); | |
42 | } | |
43 |