add proper ordering to function param logic - fixes #549
This commit is contained in:
19
test/fixtures/transformation/es6-default-parameters/destructuring/exec.js
vendored
Normal file
19
test/fixtures/transformation/es6-default-parameters/destructuring/exec.js
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
function required(msg) {
|
||||
throw new Error(msg);
|
||||
}
|
||||
|
||||
function sum(
|
||||
{ arr = required('arr is required') } = { arr: arr = [] },
|
||||
length = arr.length
|
||||
) {
|
||||
let i = 0;
|
||||
let acc = 0;
|
||||
for (let item of arr) {
|
||||
if (i >= length) return acc;
|
||||
acc += item;
|
||||
i++;
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
||||
assert.equal(sum({arr:[1,2]}), 3);
|
||||
Reference in New Issue
Block a user