mirror of
https://github.com/tc39/test262.git
synced 2025-08-17 16:08:29 +02:00
58 lines
1.6 KiB
Plaintext
58 lines
1.6 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 is not invoked when evaluation of AssignmentElementList
|
|
returns an abrupt completion and the iterator has been marked as "done"
|
|
info: |
|
|
ArrayAssignmentPattern :
|
|
[ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
|
|
|
|
[...]
|
|
3. Let iteratorRecord be Record {[[iterator]]: iterator, [[done]]: false}.
|
|
4. Let status be the result of performing
|
|
IteratorDestructuringAssignmentEvaluation of AssignmentElementList using
|
|
iteratorRecord as the argument.
|
|
5. If status is an abrupt completion, then
|
|
a. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
|
|
status).
|
|
b. Return Completion(status).
|
|
features: [Symbol.iterator]
|
|
template: async-generator
|
|
esid: sec-runtime-semantics-destructuringassignmentevaluation
|
|
---*/
|
|
|
|
//- setup
|
|
let nextCount = 0;
|
|
let returnCount = 0;
|
|
let iterable = {};
|
|
let thrower = function() {
|
|
throw new Test262Error();
|
|
};
|
|
let iterator = {
|
|
next() {
|
|
nextCount += 1;
|
|
throw new Test262Error();
|
|
},
|
|
return() {
|
|
returnCount += 1;
|
|
}
|
|
};
|
|
iterable[Symbol.iterator] = function() {
|
|
return iterator;
|
|
};
|
|
let x;
|
|
//- error
|
|
Test262Error
|
|
//- elems
|
|
[ x , ]
|
|
//- vals
|
|
iterable
|
|
//- teardown
|
|
iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
|
|
assert.sameValue(nextCount, 1);
|
|
assert.sameValue(returnCount, 0);
|
|
assert.sameValue(iterCount, 0);
|
|
assert.sameValue(constructor, Test262Error);
|
|
}).then($DONE, $DONE);
|