| 1 |
// |reftest| async |
| 2 |
// This file was procedurally generated from the following sources: |
| 3 |
// - src/dstr-assignment-for-await/obj-rest-descriptors.case |
| 4 |
// - src/dstr-assignment-for-await/default/async-func-decl.template |
| 5 |
/*--- |
| 6 |
description: Object created from rest deconstruction doesn't copy source object property descriptors. (for-await-of statement in an async function declaration) |
| 7 |
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation |
| 8 |
features: [object-rest, destructuring-binding, async-iteration] |
| 9 |
flags: [generated, async] |
| 10 |
includes: [propertyHelper.js] |
| 11 |
info: | |
| 12 |
IterationStatement : |
| 13 |
for await ( LeftHandSideExpression of AssignmentExpression ) Statement |
| 14 |
|
| 15 |
1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », |
| 16 |
AssignmentExpression, iterate). |
| 17 |
2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, |
| 18 |
keyResult, assignment, labelSet). |
| 19 |
|
| 20 |
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation |
| 21 |
|
| 22 |
[...] |
| 23 |
5. If destructuring is true and if lhsKind is assignment, then |
| 24 |
a. Assert: lhs is a LeftHandSideExpression. |
| 25 |
b. Let assignmentPattern be the parse of the source text corresponding to |
| 26 |
lhs using AssignmentPattern as the goal symbol. |
| 27 |
[...] |
| 28 |
---*/ |
| 29 |
let rest; |
| 30 |
let obj = {}; |
| 31 |
Object.defineProperty(obj, "a", { value: 3, configurable: false, enumerable: true }); |
| 32 |
Object.defineProperty(obj, "b", { value: 4, writable: false, enumerable: true }); |
| 33 |
|
| 34 |
let iterCount = 0; |
| 35 |
async function fn() { |
| 36 |
for await ({...rest} of [obj]) { |
| 37 |
verifyProperty(rest, "a", { |
| 38 |
enumerable: true, |
| 39 |
writable: true, |
| 40 |
configurable: true, |
| 41 |
value: 3 |
| 42 |
}); |
| 43 |
|
| 44 |
verifyProperty(rest, "b", { |
| 45 |
enumerable: true, |
| 46 |
writable: true, |
| 47 |
configurable: true, |
| 48 |
value: 4 |
| 49 |
}); |
| 50 |
iterCount += 1; |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
let promise = fn(); |
| 55 |
|
| 56 |
promise |
| 57 |
.then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) |
| 58 |
.then($DONE, $DONE); |