mirror of
https://github.com/tc39/test262.git
synced 2025-11-13 02:09:47 +01:00
55 lines
1.4 KiB
Plaintext
55 lines
1.4 KiB
Plaintext
// 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 ]
|
|
|
|
[...]
|
|
4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
|
|
5. Return result.
|
|
|
|
7.4.6 IteratorClose( iterator, completion )
|
|
|
|
[...]
|
|
5. Let innerResult be Call(return, iterator, « »).
|
|
6. If completion.[[Type]] is throw, return Completion(completion).
|
|
7. If innerResult.[[Type]] is throw, return Completion(innerResult).
|
|
8. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception.
|
|
|
|
features: [Symbol.iterator]
|
|
template: async-generator
|
|
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
|
---*/
|
|
|
|
//- setup
|
|
let _;
|
|
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;
|
|
}
|
|
};
|
|
//- elems
|
|
[ _ ]
|
|
//- vals
|
|
iterable
|
|
//- teardown
|
|
iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
|
|
assert.sameValue(nextCount, 1);
|
|
assert.sameValue(constructor, TypeError);
|
|
}).then($DONE, $DONE);
|
|
|