From 54ccd773c35a7a6740647461c1aab3af105f1cfc Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Thu, 25 May 2023 16:22:19 -0600 Subject: [PATCH] review feedback --- .../drop/exhaustion-does-not-call-return.js | 32 +++++++------------ .../filter/exhaustion-does-not-call-return.js | 32 +++++++------------ .../exhaustion-does-not-call-return.js | 32 +++++++------------ .../map/exhaustion-does-not-call-return.js | 32 +++++++------------ .../prototype/take/exhaustion-calls-return.js | 27 +++++++--------- .../toArray/iterator-already-exhausted.js | 2 +- 6 files changed, 60 insertions(+), 97 deletions(-) diff --git a/test/built-ins/Iterator/prototype/drop/exhaustion-does-not-call-return.js b/test/built-ins/Iterator/prototype/drop/exhaustion-does-not-call-return.js index a314e23eecc..744574b6cd3 100644 --- a/test/built-ins/Iterator/prototype/drop/exhaustion-does-not-call-return.js +++ b/test/built-ins/Iterator/prototype/drop/exhaustion-does-not-call-return.js @@ -16,29 +16,21 @@ info: | features: [iterator-helpers] flags: [] ---*/ +function* g() { + yield 0; + yield 1; + yield 2; +} + class TestIterator extends Iterator { - constructor() { - super(); - this._remaining = 3; - } - next() { - if (this._remaining > 0) { - return { - done: false, - value: this._remaining--, - }; - } else { - return { - done: true, - value: undefined, - }; - } + get next() { + let n = g(); + return function() { + return n.next(); + }; } return() { - if (this._remaining <= 0) { - throw new Test262Error(); - } - return {}; + throw new Test262Error(); } } diff --git a/test/built-ins/Iterator/prototype/filter/exhaustion-does-not-call-return.js b/test/built-ins/Iterator/prototype/filter/exhaustion-does-not-call-return.js index 6776509008b..7176212a162 100644 --- a/test/built-ins/Iterator/prototype/filter/exhaustion-does-not-call-return.js +++ b/test/built-ins/Iterator/prototype/filter/exhaustion-does-not-call-return.js @@ -13,29 +13,21 @@ info: | features: [iterator-helpers] flags: [] ---*/ +function* g() { + yield 0; + yield 1; + yield 2; +} + class TestIterator extends Iterator { - constructor() { - super(); - this._remaining = 3; - } - next() { - if (this._remaining > 0) { - return { - done: false, - value: this._remaining--, - }; - } else { - return { - done: true, - value: undefined, - }; - } + get next() { + let n = g(); + return function() { + return n.next(); + }; } return() { - if (this._remaining <= 0) { - throw new Test262Error(); - } - return {}; + throw new Test262Error(); } } diff --git a/test/built-ins/Iterator/prototype/flatMap/exhaustion-does-not-call-return.js b/test/built-ins/Iterator/prototype/flatMap/exhaustion-does-not-call-return.js index 5a9a5ef62bd..a33ef7ed16d 100644 --- a/test/built-ins/Iterator/prototype/flatMap/exhaustion-does-not-call-return.js +++ b/test/built-ins/Iterator/prototype/flatMap/exhaustion-does-not-call-return.js @@ -10,29 +10,21 @@ info: | features: [iterator-helpers] flags: [] ---*/ +function* g() { + yield 0; + yield 1; + yield 2; +} + class TestIterator extends Iterator { - constructor() { - super(); - this._remaining = 3; - } - next() { - if (this._remaining > 0) { - return { - done: false, - value: this._remaining--, - }; - } else { - return { - done: true, - value: undefined, - }; - } + get next() { + let n = g(); + return function() { + return n.next(); + }; } return() { - if (this._remaining <= 0) { - throw new Test262Error(); - } - return {}; + throw new Test262Error(); } } diff --git a/test/built-ins/Iterator/prototype/map/exhaustion-does-not-call-return.js b/test/built-ins/Iterator/prototype/map/exhaustion-does-not-call-return.js index ea6e0418654..e93c945ebd4 100644 --- a/test/built-ins/Iterator/prototype/map/exhaustion-does-not-call-return.js +++ b/test/built-ins/Iterator/prototype/map/exhaustion-does-not-call-return.js @@ -10,29 +10,21 @@ info: | features: [iterator-helpers] flags: [] ---*/ +function* g() { + yield 0; + yield 1; + yield 2; +} + class TestIterator extends Iterator { - constructor() { - super(); - this._remaining = 3; - } - next() { - if (this._remaining > 0) { - return { - done: false, - value: this._remaining--, - }; - } else { - return { - done: true, - value: undefined, - }; - } + get next() { + let n = g(); + return function() { + return n.next(); + }; } return() { - if (this._remaining <= 0) { - throw new Test262Error(); - } - return {}; + throw new Test262Error(); } } diff --git a/test/built-ins/Iterator/prototype/take/exhaustion-calls-return.js b/test/built-ins/Iterator/prototype/take/exhaustion-calls-return.js index b7f0e46167e..ae50a2a7dd0 100644 --- a/test/built-ins/Iterator/prototype/take/exhaustion-calls-return.js +++ b/test/built-ins/Iterator/prototype/take/exhaustion-calls-return.js @@ -13,23 +13,18 @@ info: | features: [iterator-helpers] flags: [] ---*/ +function* g() { + yield 0; + yield 1; + yield 2; +} + class TestIterator extends Iterator { - constructor() { - super(); - this._remaining = 3; - } - next() { - if (this._remaining > 0) { - return { - done: false, - value: this._remaining--, - }; - } else { - return { - done: true, - value: undefined, - }; - } + get next() { + let n = g(); + return function() { + return n.next(); + }; } return() { throw new Test262Error(); diff --git a/test/built-ins/Iterator/prototype/toArray/iterator-already-exhausted.js b/test/built-ins/Iterator/prototype/toArray/iterator-already-exhausted.js index 96f28d516d6..9db33a71aca 100644 --- a/test/built-ins/Iterator/prototype/toArray/iterator-already-exhausted.js +++ b/test/built-ins/Iterator/prototype/toArray/iterator-already-exhausted.js @@ -3,7 +3,7 @@ /*--- esid: sec-iteratorprototype.toArray description: > - Iterator.prototype.toArray returns undefined when the iterator has already been exhausted + Iterator.prototype.toArray returns an empty array when the iterator has already been exhausted info: | %Iterator.prototype%.toArray ( )