~ubuntu-branches/ubuntu/quantal/php5/quantal

« back to all changes in this revision

Viewing changes to ext/spl/tests/heap_004.phpt

  • Committer: Bazaar Package Importer
  • Author(s): Sean Finney
  • Date: 2009-07-01 09:12:10 UTC
  • mto: (0.9.1) (1.1.17 upstream)
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: james.westby@ubuntu.com-20090701091210-go0h6506p62on17r
Tags: upstream-5.3.0
ImportĀ upstreamĀ versionĀ 5.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--TEST--
 
2
SPL: SplHeap: exceptions
 
3
--FILE--
 
4
<?php
 
5
class myHeap extends SplHeap {
 
6
    public function compare($a, $b) {
 
7
        throw new exception("foo");
 
8
    }
 
9
}
 
10
 
 
11
$h = new myHeap;
 
12
 
 
13
try {
 
14
    $h->insert(1);
 
15
    echo "inserted 1\n";
 
16
    $h->insert(2);
 
17
    echo "inserted 2\n";
 
18
    $h->insert(3);
 
19
    echo "inserted 3\n";
 
20
} catch(Exception $e) {
 
21
    echo "Exception: ".$e->getMessage()."\n";
 
22
}
 
23
 
 
24
try {
 
25
    $h->insert(4);
 
26
    echo "inserted 4\n";
 
27
} catch(Exception $e) {
 
28
    echo "Exception: ".$e->getMessage()."\n";
 
29
}
 
30
 
 
31
try {
 
32
    var_dump($h->extract());
 
33
} catch(Exception $e) {
 
34
    echo "Exception: ".$e->getMessage()."\n";
 
35
}
 
36
try {
 
37
    var_dump($h->extract());
 
38
} catch(Exception $e) {
 
39
    echo "Exception: ".$e->getMessage()."\n";
 
40
}
 
41
 
 
42
echo "Recovering..\n";
 
43
$h->recoverFromCorruption();
 
44
 
 
45
try {
 
46
    var_dump($h->extract());
 
47
} catch(Exception $e) {
 
48
    echo "Exception: ".$e->getMessage()."\n";
 
49
}
 
50
try {
 
51
    var_dump($h->extract());
 
52
} catch(Exception $e) {
 
53
    echo "Exception: ".$e->getMessage()."\n";
 
54
}
 
55
?>
 
56
===DONE===
 
57
<?php exit(0); ?>
 
58
--EXPECTF--
 
59
inserted 1
 
60
Exception: foo
 
61
Exception: Heap is corrupted, heap properties are no longer ensured.
 
62
Exception: Heap is corrupted, heap properties are no longer ensured.
 
63
Exception: Heap is corrupted, heap properties are no longer ensured.
 
64
Recovering..
 
65
int(1)
 
66
int(2)
 
67
===DONE===