summaryrefslogtreecommitdiff
path: root/Zend/tests
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/tests')
-rw-r--r--Zend/tests/bug69989_1.phpt15
-rw-r--r--Zend/tests/bug71470.phpt13
-rw-r--r--Zend/tests/bug71529.phpt23
-rw-r--r--Zend/tests/bug71622.phpt30
-rw-r--r--Zend/tests/foreach_017.phpt2
-rw-r--r--Zend/tests/generators/bug71601.phpt40
-rw-r--r--Zend/tests/generators/dangling_send_target.phpt22
-rw-r--r--Zend/tests/generators/yield_from_by_reference.phpt12
8 files changed, 156 insertions, 1 deletions
diff --git a/Zend/tests/bug69989_1.phpt b/Zend/tests/bug69989_1.phpt
new file mode 100644
index 0000000000..816c55410e
--- /dev/null
+++ b/Zend/tests/bug69989_1.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #69989: Cycle collection for yielded values
+--FILE--
+<?php
+
+function gen() {
+ yield yield;
+}
+$gen = gen();
+$gen->send($gen);
+
+?>
+===DONE===
+--EXPECT--
+===DONE===
diff --git a/Zend/tests/bug71470.phpt b/Zend/tests/bug71470.phpt
new file mode 100644
index 0000000000..6f8b4f0103
--- /dev/null
+++ b/Zend/tests/bug71470.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #71470: Leaked 1 hashtable iterators
+--FILE--
+<?php
+
+$array = [1, 2, 3];
+foreach ($array as &$v) {
+ die("foo\n");
+}
+
+?>
+--EXPECT--
+foo
diff --git a/Zend/tests/bug71529.phpt b/Zend/tests/bug71529.phpt
new file mode 100644
index 0000000000..5a5e323414
--- /dev/null
+++ b/Zend/tests/bug71529.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #71529: Variable references on array elements don't work when using count
+--FILE--
+<?php
+
+$a = [1];
+$a[] = &$a[out(count($a) - 1)];
+var_dump($a);
+
+function out($what) {
+ var_dump($what);
+ return $what;
+}
+
+?>
+--EXPECT--
+int(0)
+array(2) {
+ [0]=>
+ &int(1)
+ [1]=>
+ &int(1)
+}
diff --git a/Zend/tests/bug71622.phpt b/Zend/tests/bug71622.phpt
new file mode 100644
index 0000000000..3ef0ba80e1
--- /dev/null
+++ b/Zend/tests/bug71622.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Bug #71622 (Strings used in pass-as-reference cannot be used to invoke C::$callable())
+--FILE--
+<?php
+
+function getMethodName(&$methodName) {
+ $methodName = Abc::METHOD_NAME;
+}
+
+class Abc {
+ const METHOD_NAME = "goal";
+
+ private static function goal() {
+ echo "success\n";
+ }
+
+ public static function run() {
+ $method = "foobar";
+ getMethodName($method);
+ var_dump(is_callable("self::$method"));
+ self::$method();
+ }
+}
+
+Abc::run();
+
+?>
+--EXPECT--
+bool(true)
+success
diff --git a/Zend/tests/foreach_017.phpt b/Zend/tests/foreach_017.phpt
index 55eeeb0891..e27b04c934 100644
--- a/Zend/tests/foreach_017.phpt
+++ b/Zend/tests/foreach_017.phpt
@@ -45,7 +45,7 @@ $done = 0;
$a = [0,1,2,3,4];
foreach($a as &$v) {
echo "$v\n";
- if ($done && $v == 3) {
+ if (!$done && $v == 3) {
$done = 1;
array_splice($a, 1, 2, $replacement);
}
diff --git a/Zend/tests/generators/bug71601.phpt b/Zend/tests/generators/bug71601.phpt
new file mode 100644
index 0000000000..e3f21692e7
--- /dev/null
+++ b/Zend/tests/generators/bug71601.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Bug #71601 (finally block not executed after yield from)
+--FILE--
+<?php
+
+function gen1() {
+ try {
+ yield 1;
+ yield 2;
+ return true;
+ } finally {
+ echo "Inner finally\n";
+ }
+}
+
+function gen2() {
+ try {
+ echo "Entered try/catch\n";
+ var_dump(yield from gen1());
+ } finally {
+ echo "Finally\n";
+ }
+}
+
+$generator = gen2();
+
+var_dump($generator->current());
+
+unset($generator);
+
+echo "Done\n";
+
+?>
+--EXPECT--
+Entered try/catch
+int(1)
+Inner finally
+Finally
+Done
+
diff --git a/Zend/tests/generators/dangling_send_target.phpt b/Zend/tests/generators/dangling_send_target.phpt
new file mode 100644
index 0000000000..c62c24a2f5
--- /dev/null
+++ b/Zend/tests/generators/dangling_send_target.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Yield from does not leave a dangling send target
+--FILE--
+<?php
+function gen1() {
+ yield from [yield];
+}
+
+$gen = gen1();
+$gen->send(new stdClass);
+
+function gen2() {
+ $x = yield;
+ yield from [1, 2, 3];
+}
+$gen = gen2();
+$gen->send(new stdClass);
+$gen->send(new stdClass);
+?>
+===DONE===
+--EXPECT--
+===DONE===
diff --git a/Zend/tests/generators/yield_from_by_reference.phpt b/Zend/tests/generators/yield_from_by_reference.phpt
new file mode 100644
index 0000000000..8412a32af5
--- /dev/null
+++ b/Zend/tests/generators/yield_from_by_reference.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Yield from by reference is not supported
+--FILE--
+<?php
+
+function &gen() {
+ yield from [];
+}
+
+?>
+--EXPECTF--
+Fatal error: Cannot use "yield from" inside a by-reference generator in %s on line %d