summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2012-06-25 21:41:50 +0200
committerNikita Popov <nikic@php.net>2012-06-25 21:41:50 +0200
commit5a9bddba6699d056383107728392048cd7ccb598 (patch)
treeb3941a68d4e817e70ae0f8f2c84c1ff864830027
parentab75ed6ba9b5eace710976bf76d631728d4bb403 (diff)
downloadphp-git-5a9bddba6699d056383107728392048cd7ccb598.tar.gz
Forgot to git add two tests
-rw-r--r--Zend/tests/generators/close_inside_generator.phpt22
-rw-r--r--Zend/tests/generators/func_get_args.phpt20
2 files changed, 42 insertions, 0 deletions
diff --git a/Zend/tests/generators/close_inside_generator.phpt b/Zend/tests/generators/close_inside_generator.phpt
new file mode 100644
index 0000000000..41a91c9fc7
--- /dev/null
+++ b/Zend/tests/generators/close_inside_generator.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Calling close() during the exectution of the generator
+--FILE--
+<?php
+
+function *gen() {
+ /* Pass the generator object itself in */
+ $gen = yield;
+
+ /* Close generator while it is currently running */
+ $gen->close();
+
+ echo "Still running";
+}
+
+$gen = gen();
+$gen->send($gen);
+
+?>
+--EXPECTF--
+Warning: A generator cannot be closed while it is running in %s on line %d
+Still running
diff --git a/Zend/tests/generators/func_get_args.phpt b/Zend/tests/generators/func_get_args.phpt
new file mode 100644
index 0000000000..7ce7fb002f
--- /dev/null
+++ b/Zend/tests/generators/func_get_args.phpt
@@ -0,0 +1,20 @@
+--TEST--
+func_get_args() can be used inside generator functions
+--FILE--
+<?php
+
+function *gen() {
+ var_dump(func_get_args());
+}
+
+$gen = gen("foo", "bar");
+$gen->rewind();
+
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "bar"
+}