Skip to content

Commit

Permalink
Readded tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Jul 10, 2015
1 parent bafe9d8 commit 3bb70fe
Show file tree
Hide file tree
Showing 8 changed files with 243 additions and 0 deletions.
29 changes: 29 additions & 0 deletions 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
25 changes: 25 additions & 0 deletions 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==
32 changes: 32 additions & 0 deletions 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==
21 changes: 21 additions & 0 deletions 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==
46 changes: 46 additions & 0 deletions 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==
50 changes: 50 additions & 0 deletions 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==
18 changes: 18 additions & 0 deletions 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
22 changes: 22 additions & 0 deletions 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

0 comments on commit 3bb70fe

Please sign in to comment.