From 1e264fc509b0de2e6fa312bca0a7e49925e5991a Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Wed, 28 Apr 2004 20:10:21 +0000 Subject: [PATCH] - Add tests for the examples --- ext/spl/examples/tests/examples.inc | 25 +++++++++++ ext/spl/examples/tests/iterators_001.phpt | 20 +++++++++ ext/spl/examples/tests/iterators_002.phpt | 53 +++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100755 ext/spl/examples/tests/examples.inc create mode 100755 ext/spl/examples/tests/iterators_001.phpt create mode 100755 ext/spl/examples/tests/iterators_002.phpt diff --git a/ext/spl/examples/tests/examples.inc b/ext/spl/examples/tests/examples.inc new file mode 100755 index 0000000000..da7016e192 --- /dev/null +++ b/ext/spl/examples/tests/examples.inc @@ -0,0 +1,25 @@ +append($path . '/' . strtolower($c) . '.inc'); + } + } +} + +$classes = array( + 'EmptyIterator', + 'InfiniteIterator', +); + +foreach (new IncludeFiles(dirname(__FILE__). '/..', $classes) as $file) +{ + require_once($file); +} + +?> \ No newline at end of file diff --git a/ext/spl/examples/tests/iterators_001.phpt b/ext/spl/examples/tests/iterators_001.phpt new file mode 100755 index 0000000000..5b4a6ffd0f --- /dev/null +++ b/ext/spl/examples/tests/iterators_001.phpt @@ -0,0 +1,20 @@ +--TEST-- +SPL: EmptyIterator +--FILE-- + $val) +{ + echo "$key=>$val\n"; +} + +?> +===DONE=== +$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=== +C +3=>D +0=>A +1=>B +2=>C +===Infinite/LimitIterator=== +1=>B +2=>C +1=>B +2=>C +1=>B +===DONE=== -- 2.40.0