| 1 |
// This file was procedurally generated from the following sources: |
| 2 |
// - src/spread/mult-iter.case |
| 3 |
// - src/spread/default/member-expr.template |
| 4 |
/*--- |
| 5 |
description: Spread operator following other arguments with a valid iterator (`new` operator) |
| 6 |
esid: sec-new-operator-runtime-semantics-evaluation |
| 7 |
es6id: 12.3.3.1 |
| 8 |
features: [Symbol.iterator] |
| 9 |
flags: [generated] |
| 10 |
info: | |
| 11 |
MemberExpression : new MemberExpression Arguments |
| 12 |
|
| 13 |
1. Return EvaluateNew(MemberExpression, Arguments). |
| 14 |
|
| 15 |
12.3.3.1.1 Runtime Semantics: EvaluateNew |
| 16 |
|
| 17 |
6. If arguments is empty, let argList be an empty List. |
| 18 |
7. Else, |
| 19 |
a. Let argList be ArgumentListEvaluation of arguments. |
| 20 |
[...] |
| 21 |
|
| 22 |
12.3.6.1 Runtime Semantics: ArgumentListEvaluation |
| 23 |
|
| 24 |
ArgumentList : ... AssignmentExpression |
| 25 |
|
| 26 |
1. Let list be an empty List. |
| 27 |
2. Let spreadRef be the result of evaluating AssignmentExpression. |
| 28 |
3. Let spreadObj be GetValue(spreadRef). |
| 29 |
4. Let iterator be GetIterator(spreadObj). |
| 30 |
5. ReturnIfAbrupt(iterator). |
| 31 |
6. Repeat |
| 32 |
a. Let next be IteratorStep(iterator). |
| 33 |
b. ReturnIfAbrupt(next). |
| 34 |
c. If next is false, return list. |
| 35 |
d. Let nextArg be IteratorValue(next). |
| 36 |
e. ReturnIfAbrupt(nextArg). |
| 37 |
f. Append nextArg as the last element of list. |
| 38 |
---*/ |
| 39 |
var iter = {}; |
| 40 |
iter[Symbol.iterator] = function() { |
| 41 |
var nextCount = 3; |
| 42 |
return { |
| 43 |
next: function() { |
| 44 |
nextCount += 1; |
| 45 |
return { done: nextCount === 6, value: nextCount }; |
| 46 |
} |
| 47 |
}; |
| 48 |
}; |
| 49 |
|
| 50 |
var callCount = 0; |
| 51 |
|
| 52 |
new function() { |
| 53 |
assert.sameValue(arguments.length, 5); |
| 54 |
assert.sameValue(arguments[0], 1); |
| 55 |
assert.sameValue(arguments[1], 2); |
| 56 |
assert.sameValue(arguments[2], 3); |
| 57 |
assert.sameValue(arguments[3], 4); |
| 58 |
assert.sameValue(arguments[4], 5); |
| 59 |
callCount += 1; |
| 60 |
}(1, 2, 3, ...iter); |
| 61 |
|
| 62 |
assert.sameValue(callCount, 1); |