summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2015-07-10 03:46:57 +0300
committerDmitry Stogov <dmitry@zend.com>2015-07-10 03:46:57 +0300
commit3bb70fe2903acf2caf2600345f07943f34a3b23c (patch)
treecc8eda7cb3bab8c742bbbd9fafb6f3ce0584fdde
parentbafe9d8c306659ca0a6897951e5aac428a11fb58 (diff)
downloadphp-git-3bb70fe2903acf2caf2600345f07943f34a3b23c.tar.gz
Readded tests
-rw-r--r--Zend/tests/jump15.phpt29
-rw-r--r--Zend/tests/temporary_cleaning_001.phpt25
-rw-r--r--Zend/tests/temporary_cleaning_002.phpt32
-rw-r--r--Zend/tests/temporary_cleaning_003.phpt21
-rw-r--r--Zend/tests/temporary_cleaning_004.phpt46
-rw-r--r--Zend/tests/temporary_cleaning_005.phpt50
-rw-r--r--Zend/tests/temporary_cleaning_006.phpt18
-rw-r--r--Zend/tests/temporary_cleaning_007.phpt22
8 files changed, 243 insertions, 0 deletions
diff --git a/Zend/tests/jump15.phpt b/Zend/tests/jump15.phpt
new file mode 100644
index 0000000000..456d27785d
--- /dev/null
+++ b/Zend/tests/jump15.phpt
@@ -0,0 +1,29 @@
+--TEST--
+jump 15: goto from loop (forward)
+--FILE--
+<?php
+$ar = array("1","2","3");
+foreach ($ar as $val) {
+ switch ($val) {
+ case "1":
+ echo "1: ok\n";
+ break;
+ case "2":
+ echo "2: ok\n";
+ goto L1;
+ case "3":
+ echo "bug\n";
+ break;
+ }
+}
+echo "bug\n";
+L1:
+try {
+ echo "3: ok\n";
+} finally {
+}
+?>
+--EXPECT--
+1: ok
+2: ok
+3: ok
diff --git a/Zend/tests/temporary_cleaning_001.phpt b/Zend/tests/temporary_cleaning_001.phpt
new file mode 100644
index 0000000000..40340bc3da
--- /dev/null
+++ b/Zend/tests/temporary_cleaning_001.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Temporary leak on exception
+--XFAIL--
+See Bug #62210 and attempt to fix it in "tmp_livelibess" branch
+--FILE--
+<?php
+
+function ops() {
+ throw new Exception();
+}
+
+try {
+ $x = 2;
+ $y = new stdClass;
+ while ($x-- && new stdClass) {
+ $r = [$x] + ($y ? ((array) $x) + [2] : ops());
+ $y = (array) $y;
+ }
+} catch (Exception $e) {
+}
+
+?>
+==DONE==
+--EXPECT--
+==DONE==
diff --git a/Zend/tests/temporary_cleaning_002.phpt b/Zend/tests/temporary_cleaning_002.phpt
new file mode 100644
index 0000000000..bea54e7f77
--- /dev/null
+++ b/Zend/tests/temporary_cleaning_002.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Temporary leak on rope (encapsed string)
+--FILE--
+<?php
+class Obj {
+ function __get($x) {
+ throw new Exception();
+ }
+}
+
+$x = new Obj;
+$y = 0;
+
+try {
+ $r = "$y|$x->x|";
+} catch (Exception $e) {
+}
+
+try {
+ $r = "$x->x|$y|";
+} catch (Exception $e) {
+}
+
+try {
+ $r = "$y|$y|$x->x";
+} catch (Exception $e) {
+}
+
+?>
+==DONE==
+--EXPECT--
+==DONE==
diff --git a/Zend/tests/temporary_cleaning_003.phpt b/Zend/tests/temporary_cleaning_003.phpt
new file mode 100644
index 0000000000..0f7d9450eb
--- /dev/null
+++ b/Zend/tests/temporary_cleaning_003.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Fundamental memory leak test on temporaries
+--XFAIL--
+See Bug #62210 and attempt to fix it in "tmp_livelibess" branch
+--FILE--
+<?php
+
+function ops() {
+ throw new Exception();
+}
+
+try{
+ $x = 1;
+ $r = [$x] + ops();
+} catch (Exception $e) {
+}
+
+?>
+==DONE==
+--EXPECT--
+==DONE==
diff --git a/Zend/tests/temporary_cleaning_004.phpt b/Zend/tests/temporary_cleaning_004.phpt
new file mode 100644
index 0000000000..e2b093654f
--- /dev/null
+++ b/Zend/tests/temporary_cleaning_004.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Temporary leak with switch
+--XFAIL--
+See Bug #62210 and attempt to fix it in "tmp_livelibess" branch
+--FILE--
+<?php
+
+function ops() {
+ throw new Exception();
+}
+
+$a = [new stdClass, new stdClass];
+switch ($a[0]) {
+ case false:
+ break;
+ default:
+ try {
+ $x = 2;
+ $y = new stdClass;
+ while ($x-- && new stdClass) {
+ $r = [$x] + ($y ? ((array) $x) + [2] : ops());
+ $y = (array) $y;
+ }
+ } catch (Exception $e) {
+ }
+}
+
+try {
+ switch ($a[0]) {
+ case false:
+ break;
+ default:
+ $x = 2;
+ $y = new stdClass;
+ while ($x-- && new stdClass) {
+ $r = [$x] + ($y ? ((array) $x) + [2] : ops());
+ $y = (array) $y;
+ }
+ }
+} catch (Exception $e) {
+}
+
+?>
+==DONE==
+--EXPECT--
+==DONE==
diff --git a/Zend/tests/temporary_cleaning_005.phpt b/Zend/tests/temporary_cleaning_005.phpt
new file mode 100644
index 0000000000..f671c32543
--- /dev/null
+++ b/Zend/tests/temporary_cleaning_005.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Temporary leak with foreach
+--XFAIL--
+See Bug #62210 and attempt to fix it in "tmp_livelibess" branch
+--FILE--
+<?php
+
+function ops() {
+ throw new Exception();
+}
+
+$a = [new stdClass, new stdClass];
+foreach ([$a, [new stdClass]] as $b) {
+ switch ($b[0]) {
+ case false:
+ break;
+ default:
+ try {
+ $x = 2;
+ $y = new stdClass;
+ while ($x-- && new stdClass) {
+ $r = [$x] + ($y ? ((array) $x) + [2] : ops());
+ $y = (array) $y;
+ }
+ } catch (Exception $e) {
+ }
+ }
+}
+
+foreach ([$a, [new stdClass]] as $b) {
+ try {
+ switch ($b[0]) {
+ case false:
+ break;
+ default:
+ $x = 2;
+ $y = new stdClass;
+ while ($x-- && new stdClass) {
+ $r = [$x] + ($y ? ((array) $x) + [2] : ops());
+ $y = (array) $y;
+ }
+ }
+ } catch (Exception $e) {
+ }
+}
+
+?>
+==DONE==
+--EXPECT--
+==DONE==
diff --git a/Zend/tests/temporary_cleaning_006.phpt b/Zend/tests/temporary_cleaning_006.phpt
new file mode 100644
index 0000000000..758260d55a
--- /dev/null
+++ b/Zend/tests/temporary_cleaning_006.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Exception after separation during indirect write to fcall result
+--FILE--
+<?php
+
+function throwing() { throw new Exception; }
+
+function getArray() { return [0]; }
+
+try {
+ getArray()[throwing()] = 1;
+} catch (Exception $e) {
+ echo "Exception\n";
+}
+
+?>
+--EXPECT--
+Exception
diff --git a/Zend/tests/temporary_cleaning_007.phpt b/Zend/tests/temporary_cleaning_007.phpt
new file mode 100644
index 0000000000..0e29ed6c33
--- /dev/null
+++ b/Zend/tests/temporary_cleaning_007.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Exception inside a foreach loop with return
+--FILE--
+<?php
+class saboteurTestController {
+ public function isConsistent() { throw new \Exception(); }
+}
+
+$controllers = array(new saboteurTestController(),new saboteurTestController());
+foreach ($controllers as $controller) {
+ try {
+ if ($controller->isConsistent()) {
+ return $controller;
+ }
+ } catch (\Exception $e) {
+ echo "Exception\n";
+ }
+}
+?>
+--EXPECT--
+Exception
+Exception