Chromium Code Reviews| Index: test/mjsunit/harmony/generators-iteration.js |
| diff --git a/test/mjsunit/harmony/generators-iteration.js b/test/mjsunit/harmony/generators-iteration.js |
| index e54aeabd75cb2e9f3e93951a5ffd95358840c942..fdbc8d6bb001686a762424bcaa1a782876228b2c 100644 |
| --- a/test/mjsunit/harmony/generators-iteration.js |
| +++ b/test/mjsunit/harmony/generators-iteration.js |
| @@ -25,7 +25,8 @@ |
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| -// Flags: --harmony-generators --expose-gc |
| +// Flags: --harmony-generators --expose-gc --harmony-symbols |
|
rossberg
2014/08/05 11:58:02
Note: --harmony-symbols should be unnecessary now.
|
| +// Flags: --harmony-iteration |
| // Test generator iteration. |
| @@ -355,6 +356,32 @@ TestGenerator( |
| "foo", |
| [undefined, undefined]); |
| +// TODO(wingo): We should use TestGenerator for these, except that |
| +// currently yield* will unconditionally propagate a throw() to the |
| +// delegate iterator, which fails for these iterators that don't have |
| +// throw(). See http://code.google.com/p/v8/issues/detail?id=3484. |
| +(function() { |
| + function* g28() { |
| + yield* [1, 2, 3]; |
| + } |
| + var iter = g28(); |
| + assertIteratorResult(1, false, iter.next()); |
| + assertIteratorResult(2, false, iter.next()); |
| + assertIteratorResult(3, false, iter.next()); |
| + assertIteratorResult(undefined, true, iter.next()); |
| +})(); |
| + |
| +(function() { |
| + function* g29() { |
| + yield* "abc"; |
| + } |
| + var iter = g29(); |
| + assertIteratorResult("a", false, iter.next()); |
| + assertIteratorResult("b", false, iter.next()); |
| + assertIteratorResult("c", false, iter.next()); |
| + assertIteratorResult(undefined, true, iter.next()); |
| +})(); |
| + |
| // Generator function instances. |
| TestGenerator(GeneratorFunction(), |
| [undefined], |
| @@ -393,12 +420,16 @@ function TestDelegatingYield() { |
| function next() { |
| return results[i++]; |
| } |
| - return { next: next } |
| + var iter = { next: next }; |
| + var ret = {}; |
| + ret[Symbol.iterator] = function() { return iter; }; |
| + return ret; |
| } |
| function* yield_results(expected) { |
| return yield* results(expected); |
| } |
| - function collect_results(iter) { |
| + function collect_results(iterable) { |
| + var iter = iterable[Symbol.iterator](); |
| var ret = []; |
| var result; |
| do { |