File:
[ELWIX - Embedded LightWeight unIX -] /
embedaddon /
php /
ext /
spl /
tests /
heap_top_variation_002.phpt
Revision
1.1.1.1 (vendor branch):
download - view:
text,
annotated -
select for diffs -
revision graph
Tue Feb 21 23:48:01 2012 UTC (13 years, 4 months ago) by
misho
Branches:
php,
MAIN
CVS tags:
v5_4_3elwix,
v5_4_29p0,
v5_4_29,
v5_4_20p0,
v5_4_20,
v5_4_17p0,
v5_4_17,
v5_3_10,
HEAD
php
--TEST--
SPL: SplHeap top, corrupted heap
--CREDITS--
Mark Schaschke (mark@fractalturtle.com)
TestFest London May 2009
--FILE--
<?php
// override heap to force corruption by throwing exception in compare
class SplMinHeap2 extends SplMinHeap {
public function compare($a, $b) {
throw new Exception('Corrupt heap');
}
}
$h = new SplMinHeap2();
// insert 2 elements to hit our overridden compare
$h->insert(4);
try {
$h->insert(5);
} catch (Exception $e) {}
// call top, should fail with corrupted heap
try {
$h->top();
} catch (Exception $e) {
echo $e->getMessage();
}
?>
--EXPECTF--
Heap is corrupted, heap properties are no longer ensured.
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>