1--TEST--
2SPL: SplHeap top, corrupted heap
3--CREDITS--
4Mark Schaschke (mark@fractalturtle.com)
5TestFest London May 2009
6--FILE--
7<?php
8// override heap to force corruption by throwing exception in compare
9class SplMinHeap2 extends SplMinHeap {
10	public function compare($a, $b) {
11		throw new Exception('Corrupt heap');
12	}
13}
14
15$h = new SplMinHeap2();
16
17// insert 2 elements to hit our overridden compare
18$h->insert(4);
19try {
20	$h->insert(5);
21} catch (Exception $e) {}
22
23// call top, should fail with corrupted heap
24try {
25	$h->top();
26} catch (Exception $e) {
27	echo $e->getMessage();
28}
29?>
30--EXPECT--
31Heap is corrupted, heap properties are no longer ensured.
32