Annotation of embedaddon/php/ext/spl/tests/heap_top_variation_002.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: SPL: SplHeap top, corrupted heap
3: --CREDITS--
4: Mark Schaschke (mark@fractalturtle.com)
5: TestFest London May 2009
6: --FILE--
7: <?php
8: // override heap to force corruption by throwing exception in compare
9: class 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);
19: try {
20: $h->insert(5);
21: } catch (Exception $e) {}
22:
23: // call top, should fail with corrupted heap
24: try {
25: $h->top();
26: } catch (Exception $e) {
27: echo $e->getMessage();
28: }
29: ?>
30: --EXPECTF--
31: Heap is corrupted, heap properties are no longer ensured.
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>