Annotation of embedaddon/php/ext/spl/tests/bug37457.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Bug #37457 (Crash when an exception is thrown in accept() method of FilterIterator)
! 3: --FILE--
! 4: <?php
! 5:
! 6: class Collection implements Iterator
! 7: {
! 8: protected $array, $valid = false;
! 9:
! 10: public function __construct(array $a)
! 11: {
! 12: echo __METHOD__ . "\n";
! 13: $this->array = $a;
! 14: }
! 15:
! 16: public function current()
! 17: {
! 18: echo __METHOD__ . "\n";
! 19: return current($this->array);
! 20: }
! 21:
! 22: public function key()
! 23: {
! 24: echo __METHOD__ . "\n";
! 25: return key($this->array);
! 26: }
! 27:
! 28: public function next()
! 29: {
! 30: echo __METHOD__ . "\n";
! 31: $this->valid = (false !== next($this->array));
! 32: }
! 33:
! 34: public function valid()
! 35: {
! 36: echo __METHOD__ . "\n";
! 37: return $this->valid;
! 38: }
! 39:
! 40: public function rewind()
! 41: {
! 42: echo __METHOD__ . "\n";
! 43: $this->valid = (false !== reset($this->array));
! 44: }
! 45: }
! 46:
! 47: class TestFilter extends FilterIterator
! 48: {
! 49: public function accept()
! 50: {
! 51: echo __METHOD__ . "\n";
! 52: throw new Exception("Failure in Accept");
! 53: }
! 54: }
! 55:
! 56: $test = new TestFilter(new Collection(array(0)));
! 57:
! 58: try
! 59: {
! 60: foreach ($test as $item)
! 61: {
! 62: echo $item;
! 63: }
! 64: }
! 65: catch (Exception $e)
! 66: {
! 67: var_dump($e->getMessage());
! 68: }
! 69:
! 70: ?>
! 71: ===DONE===
! 72: --EXPECTF--
! 73: Collection::__construct
! 74: Collection::rewind
! 75: Collection::valid
! 76: Collection::current
! 77: Collection::key
! 78: TestFilter::accept
! 79: string(17) "Failure in Accept"
! 80: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>