cvs: php-src /ext/spl/examples/tests .cvsignore examples.inc iterators_001.phpt iterators_002.phpt
| From: | Marcus Boerger | Date: | Wed, 28 Apr 2004 20:10:21 +0000 |
| Subject: | cvs: php-src /ext/spl/examples/tests .cvsignore examples.inc iterators_001.phpt iterators_002.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-27211@lists.php.net to get a copy of this message | ||
helly Wed Apr 28 16:10:21 2004 EDT
Added files:
/php-src/ext/spl/examples/tests .cvsignore examples.inc
iterators_001.phpt
iterators_002.phpt
Log:
- Add tests for the examples
http://cvs.php.net/co.php/php-src/ext/spl/examples/tests/.cvsignore?r=1.1&p=1
Index: php-src/ext/spl/examples/tests/.cvsignore
+++ php-src/ext/spl/examples/tests/.cvsignore
phpt.*
*.diff
*.log
*.exp
*.out
*.php
http://cvs.php.net/co.php/php-src/ext/spl/examples/tests/examples.inc?r=1.1&p=1
Index: php-src/ext/spl/examples/tests/examples.inc
+++ php-src/ext/spl/examples/tests/examples.inc
<?php
class IncludeFiles extends ArrayIterator
{
function __construct($path, $classes)
{
parent::__construct();
foreach($classes as $c)
{
$this->append($path . '/' . strtolower($c) . '.inc');
}
}
}
$classes = array(
'EmptyIterator',
'InfiniteIterator',
);
foreach (new IncludeFiles(dirname(__FILE__). '/..', $classes) as $file)
{
require_once($file);
}
?>
http://cvs.php.net/co.php/php-src/ext/spl/examples/tests/iterators_001.phpt?r=1.1&p=1
Index: php-src/ext/spl/examples/tests/iterators_001.phpt
+++ php-src/ext/spl/examples/tests/iterators_001.phpt
--TEST--
SPL: EmptyIterator
--FILE--
<?php
require_once('examples.inc');
echo "===EmptyIterator===\n";
foreach(new LimitIterator(new EmptyIterator(), 0, 3) as $key => $val)
{
echo "$key=>$val\n";
}
?>
===DONE===
<?php exit(0);
--EXPECTF--
===EmptyIterator===
===DONE===
http://cvs.php.net/co.php/php-src/ext/spl/examples/tests/iterators_002.phpt?r=1.1&p=1
Index: php-src/ext/spl/examples/tests/iterators_002.phpt
+++ php-src/ext/spl/examples/tests/iterators_002.phpt
--TEST--
SPL: InfiniteIterator
--FILE--
<?php
require_once('examples.inc');
echo "===EmptyIterator===\n";
foreach(new LimitIterator(new InfiniteIterator(new EmptyIterator()), 0, 3) as $key=>$val)
{
echo "$key=>$val\n";
}
echo "===InfiniteIterator===\n";
$it = new ArrayIterator(array(0 => 'A', 1 => 'B', 2 => 'C', 3
=> 'D'));
$it = new InfiniteIterator($it);
$it = new LimitIterator($it, 2, 5);
foreach($it as $val=>$key)
{
echo "$val=>$key\n";
}
echo "===Infinite/LimitIterator===\n";
$it = new ArrayIterator(array(0 => 'A', 1 => 'B', 2 => 'C', 3
=> 'D'));
$it = new LimitIterator($it, 1, 2);
$it = new InfiniteIterator($it);
$it = new LimitIterator($it, 2, 5);
foreach($it as $val=>$key)
{
echo "$val=>$key\n";
}
?>
===DONE===
<?php exit(0);
--EXPECTF--
===EmptyIterator===
===InfiniteIterator===
2=>C
3=>D
0=>A
1=>B
2=>C
===Infinite/LimitIterator===
1=>B
2=>C
1=>B
2=>C
1=>B
===DONE===