Debian Codegraph @

js/src/tests/test262/language/statements/for-of/dstr/var-obj-ptrn-rest-skip-non-enumerable.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case
3 // - src/dstr-binding/default/for-of-var.template
4 /*---
5 description: Rest object doesn't contain non-enumerable properties (for-of statement)
6 esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
7 features: [object-rest, destructuring-binding]
8 flags: [generated]
9 includes: [propertyHelper.js]
10 info: |
11 IterationStatement :
12 for ( var ForBinding of AssignmentExpression ) Statement
13
14 [...]
15 3. Return ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
16 varBinding, labelSet).
17
18 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
19
20 [...]
21 3. Let destructuring be IsDestructuring of lhs.
22 [...]
23 5. Repeat
24 [...]
25 h. If destructuring is false, then
26 [...]
27 i. Else
28 i. If lhsKind is assignment, then
29 [...]
30 ii. Else if lhsKind is varBinding, then
31 1. Assert: lhs is a ForBinding.
32 2. Let status be the result of performing BindingInitialization
33 for lhs passing nextValue and undefined as the arguments.
34 [...]
35 ---*/
36 var o = {a: 3, b: 4};
37 Object.defineProperty(o, "x", { value: 4, enumerable: false });
38
39 var iterCount = 0;
40
41 for (var {...rest} of [o]) {
42 assert.sameValue(rest.x, undefined);
43
44 verifyProperty(rest, "a", {
45 enumerable: true,
46 writable: true,
47 configurable: true,
48 value: 3
49 });
50
51 verifyProperty(rest, "b", {
52 enumerable: true,
53 writable: true,
54 configurable: true,
55 value: 4
56 });
57
58 iterCount += 1;
59 }
60
61 assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
62
63 reportCompare(0, 0);