Annotation of embedaddon/php/ext/spl/tests/spl_iterator_to_array_error.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: SPL: Error: iterator_to_array when the current operation throws an exception
3: --FILE--
4: <?php
5:
6: class MyArrayIterator extends ArrayIterator {
7: public function current() {
8: throw new Exception('Make the iterator break');
9: }
10: }
11:
12: $it = new MyArrayIterator(array(4, 6, 2));
13:
14: try {
15: // get keys
16: $ar = iterator_to_array($it);
17: } catch (Exception $e) {
18: echo $e->getMessage() . PHP_EOL;
19: }
20:
21: try {
22: // get values
23: $ar = iterator_to_array($it, false);
24: } catch (Exception $e) {
25: echo $e->getMessage() . PHP_EOL;
26: }
27:
28: ?>
29:
30: <?php exit(0); ?>
31: --EXPECT--
32: Make the iterator break
33: Make the iterator break
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>