heap_top_variation_002.phpt [plain text]
--TEST--
SPL: SplHeap top, corrupted heap
--CREDITS--
Mark Schaschke (mark@fractalturtle.com)
TestFest London May 2009
--FILE--
<?php
class SplMinHeap2 extends SplMinHeap {
public function compare($a, $b) {
throw new Exception('Corrupt heap');
}
}
$h = new SplMinHeap2();
$h->insert(4);
try {
$h->insert(5);
} catch (Exception $e) {}
try {
$h->top();
} catch (Exception $e) {
echo $e->getMessage();
}
?>
--EXPECTF--
Heap is corrupted, heap properties are no longer ensured.