xref: /PHP-8.0/Zend/tests/bug79927.phpt (revision e25aab64)
1--TEST--
2Bug #79927: Generator doesn't throw exception after multiple yield from iterable
3--FILE--
4<?php
5
6$generator = (function () {
7    yield from [1, 2, 3];
8})();
9
10$generator->next();
11$generator->next();
12try {
13    $generator->rewind();
14} catch (Exception $e) {
15    echo $e->getMessage(), "\n";
16}
17echo $generator->current(), "\n";
18
19$generator2 = (function () {
20    yield from [];
21    yield 4;
22})();
23$generator2->current();
24$generator2->rewind();
25echo $generator2->current(), "\n";
26
27?>
28--EXPECT--
29Cannot rewind a generator that was already run
303
314
32