rest-elements.js (1102B)
1 // |jit-test| --ion-inlining=off; --fast-warmup 2 function calleeWithFormals(a, b, ...arr) { 3 assertEq(b, 2); 4 if (arr.length > 0) { 5 assertEq(arr[0], 3); 6 } 7 if (arr.length > 1) { 8 assertEq(arr[1], Math); 9 } 10 if (arr.length > 2) { 11 assertEq(arr[2], "foo"); 12 } 13 return arr; 14 } 15 function calleeWithoutFormals(...arr) { 16 if (arr.length > 0) { 17 assertEq(arr[0], 3); 18 } 19 if (arr.length > 1) { 20 assertEq(arr[1], Math); 21 } 22 if (arr.length > 2) { 23 assertEq(arr[2], "foo"); 24 } 25 return arr; 26 } 27 function f() { 28 for (var i = 0; i < 100; i++) { 29 assertEq(calleeWithFormals(1, 2).length, 0); 30 assertEq(calleeWithFormals(1, 2, 3).length, 1); 31 assertEq(calleeWithFormals(1, 2, 3, Math).length, 2); 32 assertEq(calleeWithFormals(1, 2, 3, Math, "foo").length, 3); 33 34 assertEq(calleeWithoutFormals().length, 0); 35 assertEq(calleeWithoutFormals(3).length, 1); 36 assertEq(calleeWithoutFormals(3, Math).length, 2); 37 assertEq(calleeWithoutFormals(3, Math, "foo").length, 3); 38 } 39 } 40 f();