bug79927.phpt 549 B

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