1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
IteratorClose throws a TypeError when `return` returns a non-Object value
info: |
ArrayAssignmentPattern :
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
[...]
6. If Elision is present, then
a. Let status be the result of performing
IteratorDestructuringAssignmentEvaluation of Elision with
iteratorRecord as the argument.
b. If status is an abrupt completion, then
[...]
8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
status).
7.4.6 IteratorClose( iterator, completion )
[...]
6. Let innerResult be Call(return, iterator, « »).
7. If completion.[[type]] is throw, return Completion(completion).
8. If innerResult.[[type]] is throw, return Completion(innerResult).
9. If Type(innerResult.[[value]]) is not Object, throw a TypeError
exception.
features: [Symbol.iterator]
template: default
es6id: 12.14.5.2
esid: sec-runtime-semantics-destructuringassignmentevaluation
---*/
//- setup
let x;
let nextCount = 0;
let iterator = {
next() {
nextCount += 1;
// Set an upper-bound to limit unnecessary iteration in non-conformant
// implementations
return { done: nextCount > 10 };
},
return() {
return null;
}
};
let iterable = {
[Symbol.iterator]() {
return iterator;
}
};
//- error
TypeError
//- elems
[ x , , ]
//- vals
iterable
//- teardown
promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
assert.sameValue(iterCount, 0);
assert.sameValue(nextCount, 2);
assert.sameValue(constructor, TypeError);
}).then($DONE, $DONE);
|