summaryrefslogtreecommitdiff
path: root/Zend/tests/generators/throw_caught.phpt
blob: 9372ba84d593dbfa2699fd8f9d856fde7852d54b (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
--TEST--
Generator::throw() where the exception is caught in the generator
--FILE--
<?php

function gen() {
    echo "before yield\n";
    try {
        yield;
    } catch (RuntimeException $e) {
        echo $e, "\n\n";
    }

    yield 'result';
}

$gen = gen();
var_dump($gen->throw(new RuntimeException('Test')));

?>
--EXPECTF--
before yield
RuntimeException: Test in %s:%d
Stack trace:
#0 {main}

string(6) "result"