| 1 |
// |reftest| async |
| 2 |
// This file was procedurally generated from the following sources: |
| 3 |
// - src/arguments/args-trailing-comma-spread-operator.case |
| 4 |
// - src/arguments/default/async-gen-named-func-expr.template |
| 5 |
/*--- |
| 6 |
description: A trailing comma should not increase the arguments.length, using spread args (async generator named function expression) |
| 7 |
esid: sec-asyncgenerator-definitions-evaluation |
| 8 |
features: [async-iteration] |
| 9 |
flags: [generated, async] |
| 10 |
info: | |
| 11 |
AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier |
| 12 |
( FormalParameters ) { AsyncGeneratorBody } |
| 13 |
|
| 14 |
[...] |
| 15 |
7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, |
| 16 |
AsyncGeneratorBody, funcEnv, strict). |
| 17 |
[...] |
| 18 |
|
| 19 |
|
| 20 |
Trailing comma in the arguments list |
| 21 |
|
| 22 |
Left-Hand-Side Expressions |
| 23 |
|
| 24 |
Arguments : |
| 25 |
( ) |
| 26 |
( ArgumentList ) |
| 27 |
( ArgumentList , ) |
| 28 |
|
| 29 |
ArgumentList : |
| 30 |
AssignmentExpression |
| 31 |
... AssignmentExpression |
| 32 |
ArgumentList , AssignmentExpression |
| 33 |
ArgumentList , ... AssignmentExpression |
| 34 |
---*/ |
| 35 |
var arr = [2, 3]; |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
var callCount = 0; |
| 40 |
// Stores a reference `ref` for case evaluation |
| 41 |
var ref; |
| 42 |
ref = async function* g() { |
| 43 |
assert.sameValue(arguments.length, 4); |
| 44 |
assert.sameValue(arguments[0], 42); |
| 45 |
assert.sameValue(arguments[1], 1); |
| 46 |
assert.sameValue(arguments[2], 2); |
| 47 |
assert.sameValue(arguments[3], 3); |
| 48 |
callCount = callCount + 1; |
| 49 |
}; |
| 50 |
|
| 51 |
ref(42, ...[1], ...arr,).next().then(() => { |
| 52 |
assert.sameValue(callCount, 1, 'generator function invoked exactly once'); |
| 53 |
}).then($DONE, $DONE); |