diff options
Diffstat (limited to '')
4 files changed, 102 insertions, 0 deletions
diff --git a/js/src/tests/non262/AsyncIterator/prototype/drop/drop-more-than-available.js b/js/src/tests/non262/AsyncIterator/prototype/drop/drop-more-than-available.js new file mode 100644 index 0000000000..45e0f91559 --- /dev/null +++ b/js/src/tests/non262/AsyncIterator/prototype/drop/drop-more-than-available.js @@ -0,0 +1,39 @@ +// |reftest| skip-if(!this.hasOwnProperty('AsyncIterator')) + +// +// +/*--- +esid: pending +description: %AsyncIterator.prototype%.drop returns if the iterator is done. +info: > + Iterator Helpers proposal 2.1.6.5 + 1. Repeat, while remaining > 0, + ... + b. Let next be ? Await(? IteratorStep(iterated)). + c. If ? IteratorComplete(next) is true, return undefined. +features: [iterator-helpers] +---*/ + +class TestIterator extends AsyncIterator { + counter = 0; + async next() { + return {done: ++this.counter >= 2, value: undefined}; + } +} + +(async () => { + let iter = [1, 2].values().drop(3); + let result = await iter.next(); + assertEq(result.value, undefined); + assertEq(result.done, true); + + iter = new TestIterator(); + let dropped = iter.drop(10); + result = await dropped.next(); + assertEq(result.value, undefined); + assertEq(result.done, true); + assertEq(iter.counter, 2); +})(); + +if (typeof reportCompare == 'function') + reportCompare(0, 0); diff --git a/js/src/tests/non262/AsyncIterator/prototype/drop/drop.js b/js/src/tests/non262/AsyncIterator/prototype/drop/drop.js new file mode 100644 index 0000000000..e380d7b7ed --- /dev/null +++ b/js/src/tests/non262/AsyncIterator/prototype/drop/drop.js @@ -0,0 +1,23 @@ +// |reftest| skip-if(!this.hasOwnProperty('AsyncIterator')) + +async function* gen() { + yield 1; + yield 2; + yield 3; +} + +let iter = gen().drop(1); + +for (const v of [2, 3]) { + iter.next().then( + ({done, value}) => { + assertEq(done, false); + assertEq(value, v); + } + ); +} + +iter.next().then(({done}) => assertEq(done, true)); + +if (typeof reportCompare === 'function') + reportCompare(0, 0); diff --git a/js/src/tests/non262/AsyncIterator/prototype/drop/length.js b/js/src/tests/non262/AsyncIterator/prototype/drop/length.js new file mode 100644 index 0000000000..6176622f17 --- /dev/null +++ b/js/src/tests/non262/AsyncIterator/prototype/drop/length.js @@ -0,0 +1,20 @@ +// |reftest| skip-if(!this.hasOwnProperty('AsyncIterator')) +// + +/*--- +esid: pending +description: %AsyncIterator.prototype%.drop length value and descriptor. +info: > +features: [iterator-helpers] +---*/ + +assertEq(AsyncIterator.prototype.drop.length, 1); + +const propertyDescriptor = Reflect.getOwnPropertyDescriptor(AsyncIterator.prototype.drop, 'length'); +assertEq(propertyDescriptor.value, 1); +assertEq(propertyDescriptor.enumerable, false); +assertEq(propertyDescriptor.writable, false); +assertEq(propertyDescriptor.configurable, true); + +if (typeof reportCompare == 'function') + reportCompare(0, 0); diff --git a/js/src/tests/non262/AsyncIterator/prototype/drop/name.js b/js/src/tests/non262/AsyncIterator/prototype/drop/name.js new file mode 100644 index 0000000000..ec0a73416a --- /dev/null +++ b/js/src/tests/non262/AsyncIterator/prototype/drop/name.js @@ -0,0 +1,20 @@ +// |reftest| skip-if(!this.hasOwnProperty('AsyncIterator')) + +/*--- +esid: pending +description: %AsyncIterator.prototype%.drop.name value and descriptor. +info: > + 17 ECMAScript Standard Built-in Objects +features: [iterator-helpers] +---*/ + +assertEq(AsyncIterator.prototype.drop.name, 'drop'); + +const propertyDescriptor = Reflect.getOwnPropertyDescriptor(AsyncIterator.prototype.drop, 'name'); +assertEq(propertyDescriptor.value, 'drop'); +assertEq(propertyDescriptor.enumerable, false); +assertEq(propertyDescriptor.writable, false); +assertEq(propertyDescriptor.configurable, true); + +if (typeof reportCompare == 'function') + reportCompare(0, 0); |