1--TEST--
2Observer: Generator with uncaught exception
3--SKIPIF--
4<?php if (!extension_loaded('zend-test')) die('skip: zend-test extension required'); ?>
5--INI--
6zend_test.observer.enabled=1
7zend_test.observer.observe_all=1
8zend_test.observer.show_return_value=1
9--FILE--
10<?php
11function fooResults() {
12    yield 0;
13    yield 1;
14    throw new RuntimeException('Oops!');
15}
16
17function doSomething() {
18    $generator = fooResults();
19    foreach ($generator as $value) {
20        echo $value . PHP_EOL;
21    }
22
23    return 'You should not see this';
24}
25
26echo doSomething() . PHP_EOL;
27?>
28--EXPECTF--
29<!-- init '%s%eobserver_generator_%d.php' -->
30<file '%s%eobserver_generator_%d.php'>
31  <!-- init doSomething() -->
32  <doSomething>
33    <!-- init fooResults() -->
34    <fooResults>
35    </fooResults:0>
360
37    <fooResults>
38    </fooResults:1>
391
40    <fooResults>
41      <!-- Exception: RuntimeException -->
42    </fooResults:NULL>
43    <!-- Exception: RuntimeException -->
44  </doSomething:NULL>
45  <!-- Exception: RuntimeException -->
46</file '%s%eobserver_generator_%d.php'>
47
48Fatal error: Uncaught RuntimeException: Oops! in %s%eobserver_generator_%d.php:%d
49Stack trace:
50#0 %s%eobserver_generator_%d.php(%d): fooResults()
51#1 %s%eobserver_generator_%d.php(%d): doSomething()
52#2 {main}
53  thrown in %s%eobserver_generator_%d.php on line %d
54