blob: f537c3fc7726e26cec28e26efc8aefab7bd88d3f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
--TEST--
Generators can throw exceptions
--FILE--
<?php
function gen() {
yield 'foo';
throw new Exception('test');
yield 'bar';
}
$gen = gen();
var_dump($gen->current());
try {
$gen->next();
} catch (Exception $e) {
echo 'Caught exception with message "', $e->getMessage(), '"', "\n";
}
var_dump($gen->current());
?>
--EXPECT--
string(3) "foo"
Caught exception with message "test"
NULL
|