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

1.1       misho       1: --TEST--
                      2: SPL: SplPriorityQueue: top and extract flags
                      3: --CREDITS--
                      4: Nathaniel McHugh nat@fishtrap.co.uk
                      5: #testfest 2009-05-09
                      6: --FILE--
                      7: <?php
                      8: 
                      9: class myPriorityQueue extends SplPriorityQueue{
                     10: 
                     11:        public function compare($a, $b){
                     12:                 if ($b == 2) {
                     13:                throw new Exception('ignore me');
                     14:                }  else {
                     15:                return parent::compare($a, $b);
                     16:                }
                     17:        }
                     18: }
                     19: 
                     20: $priorityQueue = new myPriorityQueue();
                     21: $priorityQueue->insert("a", 1);
                     22: 
                     23: try {
                     24:     //corrupt heap
                     25:     $priorityQueue->insert("b", 2);
                     26:         // ignore exception tested elsewhere
                     27: } catch (Exception $e) {
                     28: }
                     29: 
                     30: try {
                     31:     $priorityQueue->top();
                     32: } catch (RuntimeException $e) {
                     33:   echo "Exception: ".$e->getMessage().PHP_EOL;
                     34: }
                     35: 
                     36: ?>
                     37: --EXPECT--
                     38: Exception: Heap is corrupted, heap properties are no longer ensured.

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