blob: b19b82fff3fe672e716449013c095b3f3c8242b9 [file] [log] [blame]
keith_miller@apple.com85aeabb2016-06-03 23:06:39 +00001count = createBuiltin("(function () { return @argumentCount(); })");
2countNoInline = createBuiltin("(function () { return @argumentCount(); })");
3noInline(countNoInline);
4
5
6function inlineCount() { return count(); }
7noInline(inlineCount);
8
9function inlineCount1() { return count(1); }
10noInline(inlineCount1);
11
12function inlineCount2() { return count(1,2); }
13noInline(inlineCount2);
14
15function inlineCountVarArgs(list) { return count(...list); }
16noInline(inlineCountVarArgs);
17
18function assert(condition, message) {
19 if (!condition)
20 throw new Error(message);
21}
22
23for (i = 0; i < 1000000; i++) {
24 assert(count(1,1,2) === 3, i);
25 assert(count() === 0, i);
26 assert(count(1) === 1, i);
27 assert(count(...[1,2,3,4,5]) === 5, i);
28 assert(count(...[]) === 0, i);
29 assert(inlineCount() === 0, i);
30 assert(inlineCount1() === 1, i);
31 assert(inlineCount2() === 2, i);
32 assert(inlineCountVarArgs([1,2,3,4]) === 4, i);
33 assert(inlineCountVarArgs([]) === 0, i);
34 // Insert extra junk so that inlineCountVarArgs.arguments.length !== count.arguments.length
35 assert(inlineCountVarArgs([1], 2, 4) === 1, i);
36 assert(countNoInline(4) === 1, i)
37 assert(countNoInline() === 0, i);
38}