Skip to content

Commit

Permalink
https://bugs.php.net/bug.php?id=64979
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelaraujo committed Jun 21, 2013
1 parent 20dbd27 commit f8d8a2d
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Zend/tests/generators/generator_closure_static_variable.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
Closures with static variables can be generators
--FILE--
<?php

function new_closure_gen() {
return function() {
static $foo = 0;
yield ++$foo;
};
}

$closure1 = new_closure_gen();
$closure2 = new_closure_gen();

$gen1 = $closure1();
$gen2 = $closure1();
$gen3 = $closure2();

foreach (array($gen1, $gen2, $gen3) as $gen) {
foreach ($gen as $val) {
print "$val\n";
}
}

?>
--EXPECT--
int(1)
int(2)
int(1)

0 comments on commit f8d8a2d

Please sign in to comment.