]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/construct-varargs-inline-smaller-Foo.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / construct-varargs-inline-smaller-Foo.js
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 = array;
6 }
7
8 function bar(array) {
9 return new Foo(...array);
10 }
11
12 noInline(bar);
13
14 function checkEqual(a, b) {
15 if (a.length != b.length)
16 throw "Error: bad value of c, length mismatch: " + a + " versus " + b;
17 for (var i = a.length; i--;) {
18 if (a[i] != b[i])
19 throw "Error: bad value of c, mismatch at i = " + i + ": " + a + " versus " + b;
20 }
21 }
22
23 function test(array) {
24 var expected = array;
25 var actual = bar(array).f;
26 checkEqual(actual, expected);
27 }
28
29 for (var i = 0; i < 10000; ++i) {
30 var array = [];
31 for (var j = 0; j < i % 6; ++j)
32 array.push(j);
33 test(array);
34 }
35