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