Add a few phpt tests related to temporary cleaning

This commit is contained in:
Bob Weinand 2015-07-06 13:51:27 +02:00
parent 739656f83f
commit 4398dab82f
5 changed files with 166 additions and 0 deletions

View file

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

View file

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

View file

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

View file

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

View file

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