helly           Wed May 10 00:29:42 2006 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/spl/tests      iterator_027.phpt iterator_029.phpt 

  Modified files:              
    /php-src/ext/spl    spl_iterators.c 
  Log:
  - Fix iterators part and add tests
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_iterators.c?r1=1.73.2.30.2.1&r2=1.73.2.30.2.2&diff_format=u
Index: php-src/ext/spl/spl_iterators.c
diff -u php-src/ext/spl/spl_iterators.c:1.73.2.30.2.1 
php-src/ext/spl/spl_iterators.c:1.73.2.30.2.2
--- php-src/ext/spl/spl_iterators.c:1.73.2.30.2.1       Wed May 10 00:03:38 2006
+++ php-src/ext/spl/spl_iterators.c     Wed May 10 00:29:42 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_iterators.c,v 1.73.2.30.2.1 2006/05/10 00:03:38 helly Exp $ */
+/* $Id: spl_iterators.c,v 1.73.2.30.2.2 2006/05/10 00:29:42 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -1812,7 +1812,6 @@
        spl_dual_it_object   *intern;
        char *arKey;
        uint nKeyLength;
-       zend_uchar type;
        zval *value;
 
        intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() 
TSRMLS_CC);
@@ -1821,7 +1820,7 @@
                zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 
TSRMLS_CC, "%v does not use a full cache (see CachingIterator::__construct)", 
Z_OBJCE_P(getThis())->name);
        }
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Tz", &arKey, 
&nKeyLength, &type, &value) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", &arKey, 
&nKeyLength, &value) == FAILURE) {
                return;
        }
 

http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/tests/iterator_027.phpt?view=markup&rev=1.1
Index: php-src/ext/spl/tests/iterator_027.phpt
+++ php-src/ext/spl/tests/iterator_027.phpt
--TEST--
SPL: CachingIterator::FULL_CACHE
--FILE--
<?php

$ar = array(1, 2, array(31, 32, array(331)), 4);

$it = new RecursiveArrayIterator($ar);
$it = new RecursiveIteratorIterator($it);
$it = new CachingIterator($it, CachingIterator::FULL_CACHE);

foreach($it as $k=>$v)
{
        echo "$k=>$v\n";
}

echo "===CHECK===\n";

for ($i = 0; $i < 4; $i++)
{
        if (isset($it[$i]))
        {
                var_dump($i, $it[$i]);
        }
}

$it[2] = 'foo';
$it[3] = 'bar';
$it['baz'] = '25';

var_dump($it[2]);
var_dump($it[3]);
var_dump($it['baz']);

unset($it[0]);
unset($it[2]);
unset($it['baz']);

var_dump(isset($it[0])); // unset
var_dump(isset($it[1])); // still present
var_dump(isset($it[2])); // unset
var_dump(isset($it[3])); // still present
var_dump(isset($it['baz']));

echo "===REWIND===\n";

$it->rewind(); // cleans and reads first element
var_dump(isset($it[0])); // pre-fetched
var_dump(isset($it[1])); // deleted
var_dump(isset($it[2])); // unset
var_dump(isset($it[3])); // deleted

?>
===DONE===
<?php exit(0); ?>
--EXPECT--
0=>1
1=>2
0=>31
1=>32
0=>331
3=>4
===CHECK===
int(0)
int(331)
int(1)
int(32)
int(3)
int(4)
string(3) "foo"
string(3) "bar"
string(2) "25"
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
===REWIND===
bool(true)
bool(false)
bool(false)
bool(false)
===DONE===

http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/tests/iterator_029.phpt?view=markup&rev=1.1
Index: php-src/ext/spl/tests/iterator_029.phpt
+++ php-src/ext/spl/tests/iterator_029.phpt
--TEST--
SPL: RegExIterator
--FILE--
<?php

$ar = array(0, "123", 123, 22 => "abc", "a2b", 22, "a2d" => 7, 42);

foreach(new RegExIterator(new ArrayIterator($ar), "/2/", 0) as $k => $v)
{
        echo "$k=>$v\n";
}

?>
===KEY===
<?php

foreach(new RegExIterator(new ArrayIterator($ar), "/2/", 0) as $k => $v)
{
        echo "$k=>$v\n";
}

?>
===DONE===
<?php exit(0); ?>
--EXPECT--
1=>123
2=>123
23=>a2b
24=>22
25=>42
===KEY===
1=>123
2=>123
23=>a2b
24=>22
25=>42
===DONE===

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to