1--TEST--
2SPL: SplPriorityQueue: top and extract flags
3--CREDITS--
4Nathaniel McHugh nat@fishtrap.co.uk
5#testfest 2009-05-09
6--FILE--
7<?php
8
9class 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
23try {
24    //corrupt heap
25    $priorityQueue->insert("b", 2);
26        // ignore exception tested elsewhere
27} catch (Exception $e) {
28}
29
30try {
31    $priorityQueue->top();
32} catch (RuntimeException $e) {
33  echo "Exception: ".$e->getMessage().PHP_EOL;
34}
35
36?>
37--EXPECT--
38Exception: Heap is corrupted, heap properties are no longer ensured.
39