mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
Add a few phpt tests related to temporary cleaning
This commit is contained in:
parent
739656f83f
commit
4398dab82f
5 changed files with 166 additions and 0 deletions
23
Zend/tests/temporary_cleaning_001.phpt
Normal file
23
Zend/tests/temporary_cleaning_001.phpt
Normal 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==
|
32
Zend/tests/temporary_cleaning_002.phpt
Normal file
32
Zend/tests/temporary_cleaning_002.phpt
Normal 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==
|
19
Zend/tests/temporary_cleaning_003.phpt
Normal file
19
Zend/tests/temporary_cleaning_003.phpt
Normal 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==
|
44
Zend/tests/temporary_cleaning_004.phpt
Normal file
44
Zend/tests/temporary_cleaning_004.phpt
Normal 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==
|
48
Zend/tests/temporary_cleaning_005.phpt
Normal file
48
Zend/tests/temporary_cleaning_005.phpt
Normal 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==
|
Loading…
Add table
Add a link
Reference in a new issue