summaryrefslogtreecommitdiff
path: root/Zend/tests/bug79927.phpt
blob: df8f245ddfde49ea5e83d041cc5c80cbc47abe02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
--TEST--
Bug #79927: Generator doesn't throw exception after multiple yield from iterable
--FILE--
<?php

$generator = (function () {
    yield from [1, 2, 3];
})();

$generator->next();
$generator->next();
try {
    $generator->rewind();
} catch (Exception $e) {
    echo $e->getMessage(), "\n";
}
echo $generator->current(), "\n";

$generator2 = (function () {
    yield from [];
    yield 4;
})();
$generator2->current();
$generator2->rewind();
echo $generator2->current(), "\n";

?>
--EXPECT--
Cannot rewind a generator that was already run
3
4