xref: /PHP-5.4/ext/spl/tests/heap_001.phpt (revision afb1e3ef)
1--TEST--
2SPL: SplMaxHeap: std operations
3--FILE--
4<?php
5$h = new SplMaxHeap();
6
7// errors
8try {
9    $h->extract();
10} catch (RuntimeException $e) {
11    echo "Exception: ".$e->getMessage()."\n";
12}
13
14
15$h->insert(1);
16$h->insert(2);
17$h->insert(3);
18$h->insert(3);
19$h->insert(3);
20
21echo $h->count()."\n";
22echo $h->extract()."\n";
23echo $h->extract()."\n";
24echo $h->extract()."\n";
25echo $h->extract()."\n";
26echo $h->extract()."\n";
27echo $h->count()."\n";
28
29echo "--\n";
30
31$b = 4;
32$h->insert($b);
33$b = 5;
34
35$h2 = clone $h;
36echo $h->extract()."\n";
37echo $h2->extract()."\n";
38?>
39===DONE===
40<?php exit(0); ?>
41--EXPECTF--
42Exception: Can't extract from an empty heap
435
443
453
463
472
481
490
50--
514
524
53===DONE===
54