diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Iterator/prototype/toArray/iterator-already-exhausted.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Iterator/prototype/toArray/iterator-already-exhausted.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Iterator/prototype/toArray/iterator-already-exhausted.js b/js/src/tests/test262/built-ins/Iterator/prototype/toArray/iterator-already-exhausted.js new file mode 100644 index 0000000000..78cf342b1a --- /dev/null +++ b/js/src/tests/test262/built-ins/Iterator/prototype/toArray/iterator-already-exhausted.js @@ -0,0 +1,27 @@ +// |reftest| shell-option(--enable-iterator-helpers) skip-if(!this.hasOwnProperty('Iterator')||!xulRuntime.shell) -- iterator-helpers is not enabled unconditionally, requires shell-options +// Copyright (C) 2023 Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-iteratorprototype.toArray +description: > + Iterator.prototype.toArray returns an empty array when the iterator has already been exhausted +info: | + %Iterator.prototype%.toArray ( ) + +includes: [compareArray.js] +features: [iterator-helpers] +flags: [] +---*/ +let iterator = (function* () {})(); + +let { value, done } = iterator.next(); +assert.sameValue(value, undefined); +assert.sameValue(done, true); + +let result = iterator.toArray(); +assert.compareArray(result, []); + +result = iterator.toArray(); +assert.compareArray(result, []); + +reportCompare(0, 0); |