1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Ensure the spread-call optimization doesn't break when a destructuring rest
// parameter is used.
function spreadTarget() { return arguments.length; }
function spreadOpt(...[r]){ return spreadTarget(...r); }
assertEq(spreadOpt([]), 0);
assertEq(spreadOpt([10]), 1);
assertEq(spreadOpt([10, 20]), 2);
assertEq(spreadOpt([10, 20, 30]), 3);
function spreadOpt2(...[...r]){ return spreadTarget(...r); }
assertEq(spreadOpt2(), 0);
assertEq(spreadOpt2(10), 1);
assertEq(spreadOpt2(10, 20), 2);
assertEq(spreadOpt2(10, 20, 30), 3);
function spreadOpt3(r, ...[]){ return spreadTarget(...r); }
assertEq(spreadOpt3([]), 0);
assertEq(spreadOpt3([10]), 1);
assertEq(spreadOpt3([10, 20]), 2);
assertEq(spreadOpt3([10, 20, 30]), 3);
if (typeof reportCompare === "function")
reportCompare(0, 0);
|