Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/assignment/dstr-array-rest-iter-thrw-close.js

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