Arquivos
hhvm/hphp/test/quick/debugger/flow_gen_excep.php
T
Mike Magruder 96d6bab291 Cleanup flow control around exceptions
There were multiple issues with flow control when exceptions occur. Fixed these by ditching the reliance on the exception thrown interrupt and introduce an exception handler interrupt, which indicates control is about to pass to a catch clause. This gives us much better insight into how execution is flowing and how we might need to adjust an in-flight stepping operation.
2013-06-10 10:14:11 -07:00

42 linhas
801 B
PHP

<?php
// Test stepping with exceptions in continuations. This is a very simple test
// which simply confirms that exceptions flowing around continuations don't
// disturb step over.
function bar($a) {
return $a + 2;
}
function genFoo($a) {
$a = bar($a);
try {
$z = yield $a+5;
$z++;
} catch (Exception $e) {
printf("Caught %s in genFoo()\n", $e->getMessage());
}
yield $a+1;
error_log('Finished in genFoo');
}
function foo($a) {
$gen1 = genFoo($a);
$gen1->next();
while ($gen1->valid()) {
$val = $gen1->current();
var_dump($val);
try {
$gen1->raise(new Exception('Exception given to continuation '.$val));
} catch (Exception $e) {
printf("Caught %s in foo()\n", $e->getMessage());
}
}
}
function main($a) {
foo($a);
}
main(1);