mirror of
https://github.com/tc39/test262.git
synced 2025-07-20 04:24:40 +02:00
add test for tc39/proposal-iterator-sequencing#19 (#4485)
This commit is contained in:
parent
99867ff618
commit
60580a0042
47
test/built-ins/Iterator/concat/get-value-after-done.js
Normal file
47
test/built-ins/Iterator/concat/get-value-after-done.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Copyright (C) 2025 Michael Ficarra. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-iterator.concat
|
||||||
|
description: >
|
||||||
|
Iterator.concat accesses the value of a done IteratorResult, matching the behaviour of yield*
|
||||||
|
info: |
|
||||||
|
Iterator.concat ( ...items )
|
||||||
|
|
||||||
|
...
|
||||||
|
3. Let closure be a new Abstract Closure with no parameters that captures iterables and performs the following steps when called:
|
||||||
|
a. For each Record iterable of iterables, do
|
||||||
|
...
|
||||||
|
v. Repeat, while innerAlive is true,
|
||||||
|
1. Let iteratorResult be ? IteratorNext(iteratorRecord).
|
||||||
|
2. Let done be Completion(IteratorComplete(iteratorResult)).
|
||||||
|
3. If done is a throw completion, then
|
||||||
|
a. Set iteratorRecord.[[Done]] to true.
|
||||||
|
b. Return ? done.
|
||||||
|
4. Set done to ! done.
|
||||||
|
5. If done is true, then
|
||||||
|
a. Set iteratorRecord.[[Done]] to true.
|
||||||
|
b. Perform ? IteratorValue(iteratorResult).
|
||||||
|
...
|
||||||
|
features: [iterator-sequencing]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
let valueAccesses = 0;
|
||||||
|
let iter = {
|
||||||
|
[Symbol.iterator]() {
|
||||||
|
return {
|
||||||
|
next() {
|
||||||
|
return {
|
||||||
|
get value() {
|
||||||
|
++valueAccesses;
|
||||||
|
},
|
||||||
|
done: true,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Array.from(Iterator.concat(iter, iter, iter));
|
||||||
|
|
||||||
|
assert.sameValue(valueAccesses, 3, 'Iterator.concat also accesses value getter after each iterator is done');
|
Loading…
x
Reference in New Issue
Block a user