summaryrefslogtreecommitdiff
path: root/ext/spl/tests/dllist_013.phpt
blob: b60f06392494ff78447e1c367e8cabbc707a7103 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
--TEST--
SPL: DoublyLinkedList: insert operations
--FILE--
<?php
$dll = new SplDoublyLinkedList();
// errors
try {
	$dll->add(2,5);
} catch (OutOfRangeException $e) {
	echo "Exception: ".$e->getMessage()."\n";
}

$dll->add(0,6);						//	6
$dll->add(0,3);						//	3 6
// Insert in the middle of the DLL
$dll->add(1,4);						//	3 4 6
$dll->add(2,5);						//	3 4 5 6
$dll->unshift(2);					//	2 3 5 4 6
// Insert at the beginning and end of the DLL
$dll->add(0,1);						//	1 2 3 4 5 6
$dll->add(6,7);						//	1 2 3 4 5 6 7

echo count($dll)."\n";

echo $dll->pop()."\n";
echo $dll->pop()."\n";
echo $dll->pop()."\n";
echo $dll->pop()."\n";
echo $dll->pop()."\n";
echo $dll->pop()."\n";
echo $dll->pop()."\n";
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
Exception: Offset invalid or out of range
7
7
6
5
4
3
2
1
===DONE===