Annotation of embedaddon/php/ext/spl/tests/heap_004.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: SPL: SplHeap: exceptions
! 3: --FILE--
! 4: <?php
! 5: class myHeap extends SplHeap {
! 6: public function compare($a, $b) {
! 7: throw new exception("foo");
! 8: }
! 9: }
! 10:
! 11: $h = new myHeap;
! 12:
! 13: try {
! 14: $h->insert(1);
! 15: echo "inserted 1\n";
! 16: $h->insert(2);
! 17: echo "inserted 2\n";
! 18: $h->insert(3);
! 19: echo "inserted 3\n";
! 20: } catch(Exception $e) {
! 21: echo "Exception: ".$e->getMessage()."\n";
! 22: }
! 23:
! 24: try {
! 25: $h->insert(4);
! 26: echo "inserted 4\n";
! 27: } catch(Exception $e) {
! 28: echo "Exception: ".$e->getMessage()."\n";
! 29: }
! 30:
! 31: try {
! 32: var_dump($h->extract());
! 33: } catch(Exception $e) {
! 34: echo "Exception: ".$e->getMessage()."\n";
! 35: }
! 36: try {
! 37: var_dump($h->extract());
! 38: } catch(Exception $e) {
! 39: echo "Exception: ".$e->getMessage()."\n";
! 40: }
! 41:
! 42: echo "Recovering..\n";
! 43: $h->recoverFromCorruption();
! 44:
! 45: try {
! 46: var_dump($h->extract());
! 47: } catch(Exception $e) {
! 48: echo "Exception: ".$e->getMessage()."\n";
! 49: }
! 50: try {
! 51: var_dump($h->extract());
! 52: } catch(Exception $e) {
! 53: echo "Exception: ".$e->getMessage()."\n";
! 54: }
! 55: ?>
! 56: ===DONE===
! 57: <?php exit(0); ?>
! 58: --EXPECTF--
! 59: inserted 1
! 60: Exception: foo
! 61: Exception: Heap is corrupted, heap properties are no longer ensured.
! 62: Exception: Heap is corrupted, heap properties are no longer ensured.
! 63: Exception: Heap is corrupted, heap properties are no longer ensured.
! 64: Recovering..
! 65: int(1)
! 66: int(2)
! 67: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>