Debian Codegraph @

js/src/tests/test262/language/expressions/assignment/dstr/array-elem-trlg-iter-elision-iter-nrml-close.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/dstr-assignment/array-elem-trlg-iter-elision-iter-nrml-close.case
3 // - src/dstr-assignment/default/assignment-expr.template
4 /*---
5 description: IteratorClose invoked when elision does not exhaust the iterator (AssignmentExpression)
6 esid: sec-variable-statement-runtime-semantics-evaluation
7 features: [Symbol.iterator, destructuring-binding]
8 flags: [generated]
9 info: |
10 VariableDeclaration : BindingPattern Initializer
11
12 1. Let rhs be the result of evaluating Initializer.
13 2. Let rval be GetValue(rhs).
14 3. ReturnIfAbrupt(rval).
15 4. Return the result of performing BindingInitialization for
16 BindingPattern passing rval and undefined as arguments.
17
18 ArrayAssignmentPattern :
19 [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
20
21 [...]
22 6. If Elision is present, then
23 a. Let status be the result of performing
24 IteratorDestructuringAssignmentEvaluation of Elision with
25 iteratorRecord as the argument.
26 b. If status is an abrupt completion, then
27 [...]
28 8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
29 status).
30
31 7.4.6 IteratorClose( iterator, completion )
32
33 [...]
34 6. Let innerResult be Call(return, iterator, « »).
35 [...]
36
37 ---*/
38 var nextCount = 0;
39 var returnCount = 0;
40 var thisValue = null;
41 var args = null;
42 var iterable = {};
43 var x;
44 var iterator = {
45 next: function() {
46 nextCount += 1;
47
48 // Set an upper-bound to limit unnecessary iteration in non-conformant
49 // implementations
50 return { done: nextCount > 10 };
51 },
52 return: function() {
53 returnCount += 1;
54 thisValue = this;
55 args = arguments;
56 return {};
57 }
58 };
59 iterable[Symbol.iterator] = function() {
60 return iterator;
61 };
62
63 var result;
64 var vals = iterable;
65
66 result = [ x , , ] = vals;
67
68 assert.sameValue(nextCount, 2);
69 assert.sameValue(returnCount, 1);
70 assert.sameValue(thisValue, iterator, 'correct `this` value');
71 assert(!!args, 'arguments object provided');
72 assert.sameValue(args.length, 0, 'zero arguments specified');
73
74 assert.sameValue(result, vals);
75
76 reportCompare(0, 0);