xref: /PHP-8.3/Zend/tests/generators/bug70904.phpt (revision f8d79582)
1--TEST--
2Bug #70904 (yield from incorrectly marks valid generator as finished)
3--FILE--
4<?php
5
6function g1() {
7    yield 1;
8}
9
10function g2($g1) {
11    yield from $g1;
12    echo "reached!\n";
13    yield 2;
14}
15
16$g1 = g1();
17$g2 = g2($g1);
18
19var_dump($g2->valid());
20var_dump($g2->current());
21$g1->next();
22var_dump($g1->valid());
23var_dump($g2->valid());
24var_dump($g2->current());
25$g2->next();
26var_dump($g2->valid());
27var_dump($g2->current());
28$g2->next();
29var_dump($g2->valid());
30var_dump($g2->current());
31
32?>
33--EXPECT--
34bool(true)
35int(1)
36bool(false)
37bool(true)
38int(1)
39reached!
40bool(true)
41int(2)
42bool(false)
43NULL
44