com php-src: https://bugs.php.net/bug.php?id=64 979: Zend/tests/generators/generator_closure_stat ic_variable.phpt
| From: | Stanislav Malyshev | Date: | Sun, 18 Aug 2013 22:09:43 +0000 |
| Subject: | com php-src: https://bugs.php.net/bug.php?id=64 979: Zend/tests/generators/generator_closure_stat ic_variable.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-72982@lists.php.net to get a copy of this message | ||
Commit: 47678c06c65be8cd844b1d6ee61f7645e0f9bfcf
Author: Marcel Araujo <ceceldada@gmail.com> Fri, 21 Jun 2013 18:25:51 -0300
Committer: Stanislav Malyshev <stas@php.net> Sun, 18 Aug 2013 15:09:43 -0700
Parents: b33a1a139771b677ddc0858d66111667361d478c
Branches: PHP-5.5 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=47678c06c65be8cd844b1d6ee61f7645e0f9bfcf
Log:
https://bugs.php.net/bug.php?id=64979
Changed paths:
A Zend/tests/generators/generator_closure_static_variable.phpt
Diff:
diff --git a/Zend/tests/generators/generator_closure_static_variable.phpt
b/Zend/tests/generators/generator_closure_static_variable.phpt
new file mode 100644
index 0000000..01d7240
--- /dev/null
+++ b/Zend/tests/generators/generator_closure_static_variable.phpt
@@ -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)
\ No newline at end of file