xref: /PHP-8.2/ext/spl/tests/iterator_011.phpt (revision f8d79582)
1--TEST--
2SPL: InfiniteIterator
3--FILE--
4<?php
5
6echo "===EmptyIterator===\n";
7
8foreach(new LimitIterator(new InfiniteIterator(new EmptyIterator()), 0, 3) as $key=>$val)
9{
10    echo "$key=>$val\n";
11}
12
13echo "===InfiniteIterator===\n";
14
15$it = new ArrayIterator(array(0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D'));
16$it = new InfiniteIterator($it);
17$it = new LimitIterator($it, 2, 5);
18foreach($it as $val=>$key)
19{
20    echo "$val=>$key\n";
21}
22
23echo "===Infinite/LimitIterator===\n";
24
25$it = new ArrayIterator(array(0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D'));
26$it = new LimitIterator($it, 1, 2);
27$it = new InfiniteIterator($it);
28$it = new LimitIterator($it, 2, 5);
29foreach($it as $val=>$key)
30{
31    echo "$val=>$key\n";
32}
33
34?>
35--EXPECT--
36===EmptyIterator===
37===InfiniteIterator===
382=>C
393=>D
400=>A
411=>B
422=>C
43===Infinite/LimitIterator===
441=>B
452=>C
461=>B
472=>C
481=>B
49