From: Marcus Boerger Date: Mon, 7 Nov 2005 18:38:20 +0000 (+0000) Subject: - Add new tests X-Git-Tag: php-5.1.0RC5~38 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=134b2718d40be61be2a7ee5af8b32c2a90e770cb;p=php - Add new tests --- diff --git a/ext/spl/tests/iterator_025.phpt b/ext/spl/tests/iterator_025.phpt new file mode 100755 index 0000000000..e582b1f39e --- /dev/null +++ b/ext/spl/tests/iterator_025.phpt @@ -0,0 +1,92 @@ +--TEST-- +SPL: RecursiveIteratorIterator and begin/endIteration() +--FILE-- +rewind(); +foreach($it as $v) echo "$v\n"; +var_dump($it->valid()); + +echo "===MANUAL===\n"; + +$it->rewind(); +while($it->valid()) +{ + echo $it->current() . "\n"; + $it->next(); + break; +} +$it->rewind(); +while($it->valid()) +{ + echo $it->current() . "\n"; + $it->next(); +} + +?> +===DONE=== + +--EXPECT-- +MyRecursiveIteratorIterator::beginIteration() +1 +2 +31 +32 +331 +4 +MyRecursiveIteratorIterator::endIteration() +===MORE=== +MyRecursiveIteratorIterator::beginIteration() +1 +2 +31 +32 +331 +4 +MyRecursiveIteratorIterator::endIteration() +===MORE=== +MyRecursiveIteratorIterator::beginIteration() +1 +2 +31 +32 +331 +4 +MyRecursiveIteratorIterator::endIteration() +bool(false) +===MANUAL=== +MyRecursiveIteratorIterator::beginIteration() +1 +1 +2 +31 +32 +331 +4 +MyRecursiveIteratorIterator::endIteration() +===DONE=== diff --git a/ext/spl/tests/iterator_026.phpt b/ext/spl/tests/iterator_026.phpt new file mode 100755 index 0000000000..8df96f0d2c --- /dev/null +++ b/ext/spl/tests/iterator_026.phpt @@ -0,0 +1,34 @@ +--TEST-- +SPL: CachingIterator::hasNext() +--FILE-- +$v) +{ + echo "$k=>$v\n"; + echo "hasNext: " . ($it->getInnerIterator()->hasNext() ? "yes" : "no") . "\n"; +} + +?> +===DONE=== + +--EXPECT-- +0=>1 +hasNext: yes +1=>2 +hasNext: yes +0=>31 +hasNext: yes +1=>32 +hasNext: yes +0=>331 +hasNext: no +3=>4 +hasNext: no +===DONE=== diff --git a/ext/spl/tests/iterator_028.phpt b/ext/spl/tests/iterator_028.phpt new file mode 100755 index 0000000000..7ec76d8144 --- /dev/null +++ b/ext/spl/tests/iterator_028.phpt @@ -0,0 +1,170 @@ +--TEST-- +SPL: RecursiveIteratorIterator and setMaxDepth() +--FILE-- +getMaxDepth()); +foreach($it as $v) echo $it->getDepth() . ": $v\n"; + +echo "===2===\n"; +$it->setMaxDepth(2); +var_dump($it->getMaxDepth()); +foreach($it as $v) echo $it->getDepth() . ": $v\n"; + +echo "===X===\n"; +$it->setMaxDepth(); +var_dump($it->getMaxDepth()); +foreach($it as $v) echo $it->getDepth() . ": $v\n"; + +echo "===3===\n"; +$it->setMaxDepth(3); +var_dump($it->getMaxDepth()); +foreach($it as $v) echo $it->getDepth() . ": $v\n"; + +echo "===5===\n"; +$it->setMaxDepth(5); +var_dump($it->getMaxDepth()); +foreach($it as $v) echo $it->getDepth() . ": $v\n"; + +echo "===0===\n"; +$it->setMaxDepth(0); +var_dump($it->getMaxDepth()); +foreach($it as $v) echo $it->getDepth() . ": $v\n"; + +echo "===-1===\n"; +$it->setMaxDepth(-1); +var_dump($it->getMaxDepth()); +try +{ + $it->setMaxDepth(4); + $it->setMaxDepth(-2); +} +catch(Exception $e) +{ + var_dump($e->getMessage()); +} +var_dump($it->getMaxDepth()); +?> +===DONE=== + +--EXPECT-- +===?=== +bool(false) +0: 1 +0: 2 +1: 31 +1: 32 +2: 331 +3: 3321 +4: 33221 +0: 4 +===2=== +int(2) +0: 1 +0: 2 +1: 31 +1: 32 +2: 331 +0: 4 +===X=== +bool(false) +0: 1 +0: 2 +1: 31 +1: 32 +2: 331 +3: 3321 +4: 33221 +0: 4 +===3=== +int(3) +0: 1 +0: 2 +1: 31 +1: 32 +2: 331 +3: 3321 +0: 4 +===5=== +int(5) +0: 1 +0: 2 +1: 31 +1: 32 +2: 331 +3: 3321 +4: 33221 +0: 4 +===0=== +int(0) +0: 1 +0: 2 +0: 4 +===-1=== +bool(false) +string(33) "Parameter max_depth must be >= -1" +int(4) +===DONE=== +--UEXPECT-- +===?=== +bool(false) +0: 1 +0: 2 +1: 31 +1: 32 +2: 331 +3: 3321 +4: 33221 +0: 4 +===2=== +int(2) +0: 1 +0: 2 +1: 31 +1: 32 +2: 331 +0: 4 +===X=== +bool(false) +0: 1 +0: 2 +1: 31 +1: 32 +2: 331 +3: 3321 +4: 33221 +0: 4 +===3=== +int(3) +0: 1 +0: 2 +1: 31 +1: 32 +2: 331 +3: 3321 +0: 4 +===5=== +int(5) +0: 1 +0: 2 +1: 31 +1: 32 +2: 331 +3: 3321 +4: 33221 +0: 4 +===0=== +int(0) +0: 1 +0: 2 +0: 4 +===-1=== +bool(false) +unicode(33) "Parameter max_depth must be >= -1" +int(4) +===DONE===