Skip to content

Commit c15c082

Browse files
committed
Add test for generator and pipe behavior.
1 parent 392d8b2 commit c15c082

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Generators
3+
--FILE--
4+
<?php
5+
6+
function producer(): \Generator {
7+
yield 1;
8+
yield 2;
9+
yield 3;
10+
}
11+
12+
function map_incr(iterable $it): \Generator {
13+
foreach ($it as $val) {
14+
yield $val +1;
15+
}
16+
}
17+
18+
$result = producer() |> map_incr(...) |> iterator_to_array(...);
19+
20+
var_dump($result);
21+
?>
22+
--EXPECT--
23+
array(3) {
24+
[0]=>
25+
int(2)
26+
[1]=>
27+
int(3)
28+
[2]=>
29+
int(4)
30+
}

0 commit comments

Comments
 (0)