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