Browse Source

Add a few phpt tests related to temporary cleaning

pull/1392/head
Bob Weinand 11 years ago
parent
commit
4398dab82f
  1. 23
      Zend/tests/temporary_cleaning_001.phpt
  2. 32
      Zend/tests/temporary_cleaning_002.phpt
  3. 19
      Zend/tests/temporary_cleaning_003.phpt
  4. 44
      Zend/tests/temporary_cleaning_004.phpt
  5. 48
      Zend/tests/temporary_cleaning_005.phpt

23
Zend/tests/temporary_cleaning_001.phpt

@ -0,0 +1,23 @@
--TEST--
Temporary leak on exception
--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==

32
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==

19
Zend/tests/temporary_cleaning_003.phpt

@ -0,0 +1,19 @@
--TEST--
Fundamental memory leak test on temporaries
--FILE--
<?php
function ops() {
throw new Exception();
}
try{
$x = 1;
$r = [$x] + ops();
} catch (Exception $e) {
}
?>
==DONE==
--EXPECT--
==DONE==

44
Zend/tests/temporary_cleaning_004.phpt

@ -0,0 +1,44 @@
--TEST--
Temporary leak with switch
--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==

48
Zend/tests/temporary_cleaning_005.phpt

@ -0,0 +1,48 @@
--TEST--
Temporary leak with foreach
--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==
Loading…
Cancel
Save