Annotation of embedaddon/php/ext/spl/tests/spl_heap_count_basic.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: SPL: SplHeap, Test spl_heap_object_count_elements (spl_heap.c:490) for returning count() failure for Heaps
                      3: --CREDITS--
                      4: Chris Scott chris.scott@nstein.com
                      5: #testfest London 2009-05-09
                      6: --FILE--
                      7: <?php
                      8: 
                      9: class MyHeap extends SplHeap
                     10: {
                     11:     public function compare($a,$b)
                     12:     {
                     13:         return ($a < $b);
                     14:     }
                     15: 
                     16:     public function count() // override count to force failure
                     17:     {
                     18:         throw new Exception('Cause count to fail');
                     19:         return parent::count();
                     20:     }
                     21: }
                     22: 
                     23: 
                     24: $heap = new MyHeap();
                     25: $heap->insert(1);
                     26: count($heap);// refers to MyHeap->count() method
                     27: 
                     28: ?>
                     29: --EXPECTF--
                     30: Fatal error: Uncaught exception 'Exception' with message 'Cause count to fail' in %s
                     31: Stack trace:
                     32: #0 [internal function]: MyHeap->count()
                     33: #1 %s count(Object(MyHeap))
                     34: #2 {main}
                     35:   thrown in %s on line %d

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>