diff options
author | SVN Migration <svn@php.net> | 2003-10-30 10:07:27 +0000 |
---|---|---|
committer | SVN Migration <svn@php.net> | 2003-10-30 10:07:27 +0000 |
commit | e00288b5b25766c2292b2e45596b9bc25d910111 (patch) | |
tree | d217ee89217ebab98202493d6820befb7bfdca6e /ext/spl/tests | |
parent | 0b3fe789062221deb65f7c0b15c450d9bda9bcbb (diff) | |
download | php-git-php-5.0.0b2.tar.gz |
This commit was manufactured by cvs2svn to create tag 'php_5_0_0b2'.php-5.0.0b2
Diffstat (limited to 'ext/spl/tests')
-rwxr-xr-x | ext/spl/tests/.htaccess | 3 | ||||
-rwxr-xr-x | ext/spl/tests/array.phpt | 88 | ||||
-rwxr-xr-x | ext/spl/tests/array_access_001.phpt | 163 | ||||
-rwxr-xr-x | ext/spl/tests/array_access_002.phpt | 137 | ||||
-rwxr-xr-x | ext/spl/tests/array_iterator.phpt | 138 | ||||
-rwxr-xr-x | ext/spl/tests/array_read.phpt | 208 | ||||
-rwxr-xr-x | ext/spl/tests/foreach.phpt | 202 | ||||
-rwxr-xr-x | ext/spl/tests/foreach_break.phpt | 90 | ||||
-rwxr-xr-x | ext/spl/tests/foreach_continue.phpt | 102 | ||||
-rwxr-xr-x | ext/spl/tests/foreach_non_spl.phpt | 61 | ||||
-rwxr-xr-x | ext/spl/tests/forward.phpt | 138 | ||||
-rwxr-xr-x | ext/spl/tests/sequence.phpt | 143 |
12 files changed, 0 insertions, 1473 deletions
diff --git a/ext/spl/tests/.htaccess b/ext/spl/tests/.htaccess deleted file mode 100755 index 5a01a1c16e..0000000000 --- a/ext/spl/tests/.htaccess +++ /dev/null @@ -1,3 +0,0 @@ -<IfModule mod_autoindex.c> - IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t *.php -</IfModule> diff --git a/ext/spl/tests/array.phpt b/ext/spl/tests/array.phpt deleted file mode 100755 index 1474564dc0..0000000000 --- a/ext/spl/tests/array.phpt +++ /dev/null @@ -1,88 +0,0 @@ ---TEST-- -SPL: array ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -$ar = array(0=>0, 1=>1); -$ar = new spl_array($ar); - -var_dump($ar); - -$ar[2] = 2; -var_dump($ar[2]); -var_dump($ar["3"] = 3); - -var_dump(array_merge((array)$ar, array(4=>4, 5=>5))); - -var_dump($ar["a"] = "a"); - -var_dump($ar); -var_dump($ar[0]); -var_dump($ar[6]); -var_dump($ar["b"]); - -unset($ar[1]); -unset($ar["3"]); -unset($ar["a"]); -unset($ar[7]); -unset($ar["c"]); -var_dump($ar); - -echo "Done\n"; -?> ---EXPECTF-- -object(spl_array)#1 (2) { - [0]=> - int(0) - [1]=> - int(1) -} -int(2) -int(3) -array(6) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - &int(2) - [3]=> - &int(3) - [4]=> - int(4) - [5]=> - int(5) -} -string(1) "a" -object(spl_array)#1 (5) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - &int(2) - [3]=> - &int(3) - ["a"]=> - &string(1) "a" -} -int(0) - -Notice: Undefined offset: 6 in %sarray.php on line %d -NULL - -Notice: Undefined index: b in %sarray.php on line %d -NULL - -Notice: Undefined offset: 7 in %sarray.php on line %d - -Notice: Undefined index: c in %sarray.php on line %d -object(spl_array)#1 (2) { - [0]=> - int(0) - [2]=> - &int(2) -} -Done diff --git a/ext/spl/tests/array_access_001.phpt b/ext/spl/tests/array_access_001.phpt deleted file mode 100755 index 2292749db2..0000000000 --- a/ext/spl/tests/array_access_001.phpt +++ /dev/null @@ -1,163 +0,0 @@ ---TEST-- -SPL: array_access ---SKIPIF-- -<?php - if (!extension_loaded("spl")) die("skip"); - if (!in_array("spl_array_access", spl_classes())) die("skip spl_array_access not present"); -?> ---FILE-- -<?php -class c implements spl_array_access { - - public $a = array('1st', 1, 2=>'3rd', '4th'=>4); - function exists($index) { - echo __METHOD__ . "($index)\n"; - return array_key_exists($index, $this->a); - } - function get($index) { - echo __METHOD__ . "($index)\n"; - return $this->a[$index]; - } - function set($index, $newval) { - echo __METHOD__ . "($index,$newval)\n"; - return $this->a[$index] = $newval; - } - function del($index) { - echo __METHOD__ . "($index)\n"; - unset($this->a[$index]); - } -} - -$obj = new c(); - -var_dump($obj->a); - -var_dump($obj[0]); -var_dump($obj[1]); -var_dump($obj[2]); -var_dump($obj['4th']); -var_dump($obj['5th']); -var_dump($obj[6]); - -echo "WRITE 1\n"; -$obj[1] = 'Changed 1'; -var_dump($obj[1]); -echo "WRITE 2\n"; -$obj['4th'] = 'Changed 4th'; -var_dump($obj['4th']); -echo "WRITE 3\n"; -$obj['5th'] = 'Added 5th'; -var_dump($obj['5th']); -echo "WRITE 4\n"; -$obj[6] = 'Added 6'; -var_dump($obj[6]); - -var_dump($obj[0]); -var_dump($obj[2]); - -$x = $obj[6] = 'changed 6'; -var_dump($obj[6]); -var_dump($x); - -echo "===unset===\n"; -var_dump($obj->a); -unset($obj[2]); -unset($obj['4th']); -unset($obj[7]); -unset($obj['8th']); -var_dump($obj->a); - -print "Done\n"; -?> ---EXPECTF-- -array(4) { - [0]=> - string(3) "1st" - [1]=> - int(1) - [2]=> - string(3) "3rd" - ["4th"]=> - int(4) -} -c::exists(0) -c::get(0) -string(3) "1st" -c::exists(1) -c::get(1) -int(1) -c::exists(2) -c::get(2) -string(3) "3rd" -c::exists(4th) -c::get(4th) -int(4) -c::exists(5th) - -Notice: Undefined index: 5th in %sarray_access_001.php on line %d -NULL -c::exists(6) - -Notice: Undefined index: 6 in %sarray_access_001.php on line %d -NULL -WRITE 1 -c::set(1,Changed 1) -c::exists(1) -c::get(1) -string(9) "Changed 1" -WRITE 2 -c::set(4th,Changed 4th) -c::exists(4th) -c::get(4th) -string(11) "Changed 4th" -WRITE 3 -c::set(5th,Added 5th) -c::exists(5th) -c::get(5th) -string(9) "Added 5th" -WRITE 4 -c::set(6,Added 6) -c::exists(6) -c::get(6) -string(7) "Added 6" -c::exists(0) -c::get(0) -string(3) "1st" -c::exists(2) -c::get(2) -string(3) "3rd" -c::set(6,changed 6) -c::exists(6) -c::get(6) -string(9) "changed 6" -string(9) "changed 6" -===unset=== -array(6) { - [0]=> - string(3) "1st" - [1]=> - string(9) "Changed 1" - [2]=> - string(3) "3rd" - ["4th"]=> - string(11) "Changed 4th" - ["5th"]=> - string(9) "Added 5th" - [6]=> - string(9) "changed 6" -} -c::del(2) -c::del(4th) -c::del(7) -c::del(8th) -array(4) { - [0]=> - string(3) "1st" - [1]=> - string(9) "Changed 1" - ["5th"]=> - string(9) "Added 5th" - [6]=> - string(9) "changed 6" -} -Done diff --git a/ext/spl/tests/array_access_002.phpt b/ext/spl/tests/array_access_002.phpt deleted file mode 100755 index 133e6f3f4a..0000000000 --- a/ext/spl/tests/array_access_002.phpt +++ /dev/null @@ -1,137 +0,0 @@ ---TEST-- -SPL: array_access without return in set() ---SKIPIF-- -<?php - if (!extension_loaded("spl")) die("skip"); - if (!in_array("spl_array_access", spl_classes())) die("skip spl_array_access not present"); -?> ---FILE-- -<?php -class c implements spl_array_access { - - public $a = array('1st', 1, 2=>'3rd', '4th'=>4); - - function exists($index) { - echo __METHOD__ . "($index)\n"; - return array_key_exists($index, $this->a); - } - function get($index) { - echo __METHOD__ . "($index)\n"; - return $this->a[$index]; - } - function set($index, $newval) { - echo __METHOD__ . "($index,$newval)\n"; - /* return */ $this->a[$index] = $newval; - } - function del($index) { - echo __METHOD__ . "($index)\n"; - unset($this->a[$index]); - } -} - -$obj = new c(); - -var_dump($obj->a); - -var_dump($obj[0]); -var_dump($obj[1]); -var_dump($obj[2]); -var_dump($obj['4th']); -var_dump($obj['5th']); -var_dump($obj[6]); - -echo "WRITE 1\n"; -$obj[1] = 'Changed 1'; -var_dump($obj[1]); -echo "WRITE 2\n"; -$obj['4th'] = 'Changed 4th'; -var_dump($obj['4th']); -echo "WRITE 3\n"; -$obj['5th'] = 'Added 5th'; -var_dump($obj['5th']); -echo "WRITE 4\n"; -$obj[6] = 'Added 6'; -var_dump($obj[6]); - -var_dump($obj[0]); -var_dump($obj[2]); - -$x = $obj[6] = 'changed 6'; -var_dump($obj[6]); -var_dump($x); - -print "Done\n"; -?> ---EXPECTF-- -array(4) { - [0]=> - string(3) "1st" - [1]=> - int(1) - [2]=> - string(3) "3rd" - ["4th"]=> - int(4) -} -c::exists(0) -c::get(0) -string(3) "1st" -c::exists(1) -c::get(1) -int(1) -c::exists(2) -c::get(2) -string(3) "3rd" -c::exists(4th) -c::get(4th) -int(4) -c::exists(5th) - -Notice: Undefined index: 5th in %sarray_access_002.php on line %d -NULL -c::exists(6) - -Notice: Undefined index: 6 in %sarray_access_002.php on line %d -NULL -WRITE 1 -c::set(1,Changed 1) - -Warning: Method c::set() did not return a value, using input value in %sarray_access_002.php on line %d -c::exists(1) -c::get(1) -string(9) "Changed 1" -WRITE 2 -c::set(4th,Changed 4th) - -Warning: Method c::set() did not return a value, using input value in %sarray_access_002.php on line %d -c::exists(4th) -c::get(4th) -string(11) "Changed 4th" -WRITE 3 -c::set(5th,Added 5th) - -Warning: Method c::set() did not return a value, using input value in %sarray_access_002.php on line %d -c::exists(5th) -c::get(5th) -string(9) "Added 5th" -WRITE 4 -c::set(6,Added 6) - -Warning: Method c::set() did not return a value, using input value in %sarray_access_002.php on line %d -c::exists(6) -c::get(6) -string(7) "Added 6" -c::exists(0) -c::get(0) -string(3) "1st" -c::exists(2) -c::get(2) -string(3) "3rd" -c::set(6,changed 6) - -Warning: Method c::set() did not return a value, using input value in %sarray_access_002.php on line %d -c::exists(6) -c::get(6) -string(9) "changed 6" -string(9) "changed 6" -Done diff --git a/ext/spl/tests/array_iterator.phpt b/ext/spl/tests/array_iterator.phpt deleted file mode 100755 index 751e623d1c..0000000000 --- a/ext/spl/tests/array_iterator.phpt +++ /dev/null @@ -1,138 +0,0 @@ ---TEST-- -SPL: spl_array_iterator ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -echo "==Normal==\n"; - -$arr = array(0=>0, 1=>1, 2=>2); -$obj = new spl_array($arr); - -foreach($obj as $ak=>$av) { - foreach($obj as $bk=>$bv) { - if ($ak==0 && $bk==0) { - $arr[0] = "modify"; - } - echo "$ak=>$av - $bk=>$bv\n"; - } -} - -echo "==UseRef==\n"; - -$arr = array(0=>0, 1=>1, 2=>2); -$obj = new spl_array(&$arr); - -foreach($obj as $ak=>$av) { - foreach($obj as $bk=>$bv) { - echo "$ak=>$av - $bk=>$bv\n"; - } -} - -echo "==Modify==\n"; - -$arr = array(0=>0, 1=>1, 2=>2); -$obj = new spl_array(&$arr); - -foreach($obj as $ak=>$av) { - foreach($obj as $bk=>$bv) { - if ($ak==0 && $bk==0) { - $arr[0] = "modify"; - } - echo "$ak=>$av - $bk=>$bv\n"; - } -} - -echo "==Delete==\n"; - -$arr = array(0=>0, 1=>1, 2=>2); -$obj = new spl_array(&$arr); - -foreach($obj as $ak=>$av) { - foreach($obj as $bk=>$bv) { - if ($ak==1 && $bk==1) { - unset($arr[1]); - } - echo "$ak=>$av - $bk=>$bv\n"; - } -} - -echo "==Change==\n"; - -$arr = array(0=>0, 1=>1, 2=>2); -$obj = new spl_array(&$arr); - -foreach($obj as $ak=>$av) { - foreach($obj as $bk=>$bv) { - if ($ak==1 && $bk==1) { - $arr = NULL; - } - echo "$ak=>$av - $bk=>$bv\n"; - } -} - -echo "Done\n"; -?> ---EXPECTF-- -==Normal== -0=>0 - 0=>0 -0=>0 - 1=>1 -0=>0 - 2=>2 -1=>1 - 0=>0 -1=>1 - 1=>1 -1=>1 - 2=>2 -2=>2 - 0=>0 -2=>2 - 1=>1 -2=>2 - 2=>2 -==UseRef== -0=>0 - 0=>0 -0=>0 - 1=>1 -0=>0 - 2=>2 -1=>1 - 0=>0 -1=>1 - 1=>1 -1=>1 - 2=>2 -2=>2 - 0=>0 -2=>2 - 1=>1 -2=>2 - 2=>2 -==Modify== -0=>0 - 0=>0 -0=>0 - 1=>1 -0=>0 - 2=>2 -1=>1 - 0=>modify -1=>1 - 1=>1 -1=>1 - 2=>2 -2=>2 - 0=>modify -2=>2 - 1=>1 -2=>2 - 2=>2 -==Delete== -0=>0 - 0=>0 -0=>0 - 1=>1 -0=>0 - 2=>2 -1=>1 - 0=>0 -1=>1 - 1=>1 - -Notice: spl_array_it::next(): Array was modified outside object and internal position is no longer valid in %sarray_iterator.php on line %d -1=>1 - 0=>0 -1=>1 - 2=>2 - -Notice: spl_array_it::next(): Array was modified outside object and internal position is no longer valid in %sarray_iterator.php on line %d -0=>0 - 0=>0 -0=>0 - 2=>2 -2=>2 - 0=>0 -2=>2 - 2=>2 -==Change== -0=>0 - 0=>0 -0=>0 - 1=>1 -0=>0 - 2=>2 -1=>1 - 0=>0 -1=>1 - 1=>1 - -Notice: spl_array_it::next(): Array was modified outside object and is no longer an array in %sarray_iterator.php on line %d - -Notice: spl_array_it::hasMore(): Array was modified outside object and is no longer an array in %sarray_iterator.php on line %d - -Notice: spl_array_it::next(): Array was modified outside object and is no longer an array in %sarray_iterator.php on line %d - -Notice: spl_array_it::hasMore(): Array was modified outside object and is no longer an array in %sarray_iterator.php on line %d -Done diff --git a/ext/spl/tests/array_read.phpt b/ext/spl/tests/array_read.phpt deleted file mode 100755 index 032373d52d..0000000000 --- a/ext/spl/tests/array_read.phpt +++ /dev/null @@ -1,208 +0,0 @@ ---TEST-- -SPL: array_read ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -echo "EXTERNAL\n"; - -$a = array('1st', 1, 2=>'3rd', '4th'=>4); -var_dump($a); - -class external implements spl_array_read { - - function exists($index) { - echo __METHOD__ . "($index)\n"; - return array_key_exists($index, $GLOBALS['a']); - } - - function get($index) { - echo __METHOD__ . "($index)\n"; - return $GLOBALS['a'][$index]; - } -} - -$obj = new external(); - -var_dump($obj->get(0)); -var_dump($obj->get(1)); -var_dump($obj->get(2)); -var_dump($obj->get('4th')); -var_dump($obj->get('5th')); -var_dump($obj->get(6)); - -var_dump($obj[0]); -var_dump($obj[1]); -var_dump($obj[2]); -var_dump($obj['4th']); -var_dump($obj['5th']); -var_dump($obj[6]); - -$out = $obj[0]; echo "$out\n"; -$out = $obj[1]; echo "$out\n"; -$out = $obj[2]; echo "$out\n"; -$out = $obj['4th']; echo "$out\n"; - -echo "INTERNAL\n"; - -class internal implements spl_array_read { - - public $a = array('1st', 1, 2=>'3rd', '4th'=>4); - - function exists($index) { - echo __METHOD__ . "($index)\n"; - return array_key_exists($index, $GLOBALS['a']); - } - - function get($index) { - echo __METHOD__ . "($index)\n"; - return $GLOBALS['a'][$index]; - } -} - -$obj = new internal(); - -var_dump($obj->a); - -var_dump($obj->get(0)); -var_dump($obj->get(1)); -var_dump($obj->get(2)); -var_dump($obj->get('4th')); -var_dump($obj->get('5th')); -var_dump($obj->get(6)); - -var_dump($obj[0]); -var_dump($obj[1]); -var_dump($obj[2]); -var_dump($obj['4th']); -var_dump($obj['5th']); -var_dump($obj[6]); - -$out = $obj[0]; echo "$out\n"; -$out = $obj[1]; echo "$out\n"; -$out = $obj[2]; echo "$out\n"; -$out = $obj['4th']; echo "$out\n"; - -print "Done\n"; -?> ---EXPECTF-- -EXTERNAL -array(4) { - [0]=> - string(3) "1st" - [1]=> - int(1) - [2]=> - string(3) "3rd" - ["4th"]=> - int(4) -} -external::get(0) -string(3) "1st" -external::get(1) -int(1) -external::get(2) -string(3) "3rd" -external::get(4th) -int(4) -external::get(5th) - -Notice: Undefined index: 5th in %s on line %d -NULL -external::get(6) - -Notice: Undefined offset: 6 in %s on line %d -NULL -external::exists(0) -external::get(0) -string(3) "1st" -external::exists(1) -external::get(1) -int(1) -external::exists(2) -external::get(2) -string(3) "3rd" -external::exists(4th) -external::get(4th) -int(4) -external::exists(5th) - -Notice: Undefined index: 5th in %s on line %d -NULL -external::exists(6) - -Notice: Undefined index: 6 in %s on line %d -NULL -external::exists(0) -external::get(0) -1st -external::exists(1) -external::get(1) -1 -external::exists(2) -external::get(2) -3rd -external::exists(4th) -external::get(4th) -4 -INTERNAL -array(4) { - [0]=> - string(3) "1st" - [1]=> - int(1) - [2]=> - string(3) "3rd" - ["4th"]=> - int(4) -} -internal::get(0) -string(3) "1st" -internal::get(1) -int(1) -internal::get(2) -string(3) "3rd" -internal::get(4th) -int(4) -internal::get(5th) - -Notice: Undefined index: 5th in %s on line %d -NULL -internal::get(6) - -Notice: Undefined offset: 6 in %s on line %d -NULL -internal::exists(0) -internal::get(0) -string(3) "1st" -internal::exists(1) -internal::get(1) -int(1) -internal::exists(2) -internal::get(2) -string(3) "3rd" -internal::exists(4th) -internal::get(4th) -int(4) -internal::exists(5th) - -Notice: Undefined index: 5th in %s on line %d -NULL -internal::exists(6) - -Notice: Undefined index: 6 in %s on line %d -NULL -internal::exists(0) -internal::get(0) -1st -internal::exists(1) -internal::get(1) -1 -internal::exists(2) -internal::get(2) -3rd -internal::exists(4th) -internal::get(4th) -4 -Done diff --git a/ext/spl/tests/foreach.phpt b/ext/spl/tests/foreach.phpt deleted file mode 100755 index 0a4cd91fb7..0000000000 --- a/ext/spl/tests/foreach.phpt +++ /dev/null @@ -1,202 +0,0 @@ ---TEST-- -SPL: foreach and iterator ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php -class c_iter implements spl_forward_assoc { - - private $obj; - private $num = 0; - - function __construct($obj) { - echo __METHOD__ . "\n"; - $this->num = 0; - $this->obj = $obj; - } - function current() { - echo __METHOD__ . "\n"; - return $this->num; - } - function next() { - echo __METHOD__ . "\n"; - $this->num++; - } - function hasMore() { - $more = $this->num < $this->obj->max; - echo __METHOD__ . ' = ' .($more ? 'true' : 'false') . "\n"; - return $more; - } - function key() { - echo __METHOD__ . "\n"; - switch($this->num) { - case 0: return "1st"; - case 1: return "2nd"; - case 2: return "3rd"; - default: return "???"; - } - } -} - -class c implements spl_iterator { - - public $max = 3; - - function newIterator() { - echo __METHOD__ . "\n"; - return new c_iter($this); - } -} - -$t = new c(); - -for ($iter = $t->newIterator(); $iter->hasMore(); $iter->next()) { - echo $iter->current() . "\n"; -} - -$a = array(0,1,2); -foreach($a as $v) { - echo "array:$v\n"; -} - -foreach($t as $v) { - echo "object:$v\n"; -} - -foreach($t as $v) { - foreach($t as $w) { - echo "double:$v:$w\n"; - } -} - -foreach($t as $i => $v) { - echo "object:$i=>$v\n"; -} - -print "Done\n"; -?> ---EXPECT-- -c::newIterator -c_iter::__construct -c_iter::hasMore = true -c_iter::current -0 -c_iter::next -c_iter::hasMore = true -c_iter::current -1 -c_iter::next -c_iter::hasMore = true -c_iter::current -2 -c_iter::next -c_iter::hasMore = false -array:0 -array:1 -array:2 -c::newIterator -c_iter::__construct -c_iter::hasMore = true -c_iter::current -c_iter::key -object:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -object:1 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -object:2 -c_iter::next -c_iter::hasMore = false -c::newIterator -c_iter::__construct -c_iter::hasMore = true -c_iter::current -c_iter::key -c::newIterator -c_iter::__construct -c_iter::hasMore = true -c_iter::current -c_iter::key -double:0:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -double:0:1 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -double:0:2 -c_iter::next -c_iter::hasMore = false -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -c::newIterator -c_iter::__construct -c_iter::hasMore = true -c_iter::current -c_iter::key -double:1:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -double:1:1 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -double:1:2 -c_iter::next -c_iter::hasMore = false -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -c::newIterator -c_iter::__construct -c_iter::hasMore = true -c_iter::current -c_iter::key -double:2:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -double:2:1 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -double:2:2 -c_iter::next -c_iter::hasMore = false -c_iter::next -c_iter::hasMore = false -c::newIterator -c_iter::__construct -c_iter::hasMore = true -c_iter::current -c_iter::key -object:1st=>0 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -object:2nd=>1 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -object:3rd=>2 -c_iter::next -c_iter::hasMore = false -Done diff --git a/ext/spl/tests/foreach_break.phpt b/ext/spl/tests/foreach_break.phpt deleted file mode 100755 index 184b762b84..0000000000 --- a/ext/spl/tests/foreach_break.phpt +++ /dev/null @@ -1,90 +0,0 @@ ---TEST-- -SPL: foreach and break ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php -class c_iter implements spl_forward_assoc { - - private $obj; - private $num = 0; - - function __construct($obj) { - $this->obj = $obj; - } - function current() { - echo __METHOD__ . "\n"; - return $this->num; - } - function next() { - echo __METHOD__ . "\n"; - $this->num++; - } - function hasMore() { - $more = $this->num < $this->obj->max; - echo __METHOD__ . ' = ' .($more ? 'true' : 'false') . "\n"; - return $more; - } - function key() { - echo __METHOD__ . "\n"; - switch($this->num) { - case 0: return "1st"; - case 1: return "2nd"; - case 2: return "3rd"; - default: return "???"; - } - } -} - -class c implements spl_iterator { - - public $max = 3; - - function newIterator() { - echo __METHOD__ . "\n"; - return new c_iter($this); - } -} - -$t = new c(); - -foreach($t as $v) { - foreach($t as $w) { - echo "double:$v:$w\n"; - break; - } -} - -print "Done\n"; -?> ---EXPECT-- -c::newIterator -c_iter::hasMore = true -c_iter::current -c_iter::key -c::newIterator -c_iter::hasMore = true -c_iter::current -c_iter::key -double:0:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -c::newIterator -c_iter::hasMore = true -c_iter::current -c_iter::key -double:1:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -c::newIterator -c_iter::hasMore = true -c_iter::current -c_iter::key -double:2:0 -c_iter::next -c_iter::hasMore = false -Done diff --git a/ext/spl/tests/foreach_continue.phpt b/ext/spl/tests/foreach_continue.phpt deleted file mode 100755 index 289f67e0a6..0000000000 --- a/ext/spl/tests/foreach_continue.phpt +++ /dev/null @@ -1,102 +0,0 @@ ---TEST-- -SPL: foreach and break ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php -class c_iter implements spl_forward { - - private $obj; - private $num = 0; - - function __construct($obj) { - $this->obj = $obj; - } - function current() { - echo __METHOD__ . "\n"; - return $this->num; - } - function next() { - echo __METHOD__ . "\n"; - $this->num++; - } - function hasMore() { - $more = $this->num < $this->obj->max; - echo __METHOD__ . ' = ' .($more ? 'true' : 'false') . "\n"; - return $more; - } -} - -class c implements spl_iterator { - - public $max = 4; - - function newIterator() { - echo __METHOD__ . "\n"; - return new c_iter($this); - } -} - -$t = new c(); - -foreach($t as $v) { - if ($v == 0) { - echo "continue outer\n"; - continue; - } - foreach($t as $w) { - if ($w == 1) { - echo "continue inner\n"; - continue; - } - if ($w == 2) { - echo "break inner\n"; - break; - } - echo "double:$v:$w\n"; - } - if ($v == 2) { - echo "break outer\n"; - break; - } -} - -print "Done\n"; -?> ---EXPECT-- -c::newIterator -c_iter::hasMore = true -c_iter::current -continue outer -c_iter::next -c_iter::hasMore = true -c_iter::current -c::newIterator -c_iter::hasMore = true -c_iter::current -double:1:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -continue inner -c_iter::next -c_iter::hasMore = true -c_iter::current -break inner -c_iter::next -c_iter::hasMore = true -c_iter::current -c::newIterator -c_iter::hasMore = true -c_iter::current -double:2:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -continue inner -c_iter::next -c_iter::hasMore = true -c_iter::current -break inner -break outer -Done diff --git a/ext/spl/tests/foreach_non_spl.phpt b/ext/spl/tests/foreach_non_spl.phpt deleted file mode 100755 index 71a7cb7f4d..0000000000 --- a/ext/spl/tests/foreach_non_spl.phpt +++ /dev/null @@ -1,61 +0,0 @@ ---TEST-- -SPL: foreach non spl classes ---SKIPIF-- -<?php if (0 && !extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -echo "1st try\n"; - -class c1 {} - -$obj = new c1(); - -foreach($obj as $w) { - echo "object:$w\n"; -} - -echo "2nd try\n"; - -class c2 { - - public $max = 3; - public $num = 0; - - function current() { - echo __METHOD__ . "\n"; - return $this->num; - } - function next() { - echo __METHOD__ . "\n"; - $this->num++; - } - function hasMore() { - echo __METHOD__ . "\n"; - return $this->num < $this->max; - } - function key() { - echo __METHOD__ . "\n"; - switch($this->num) { - case 0: return "1st"; - case 1: return "2nd"; - case 2: return "3rd"; - default: return "???"; - } - } -} - -$obj = new c2(); - -foreach($obj as $v => $w) { - echo "object:$v=>$w\n"; -} - -print "Done\n"; -?> ---EXPECTF-- -1st try -2nd try -object:max=>3 -object:num=>0 -Done diff --git a/ext/spl/tests/forward.phpt b/ext/spl/tests/forward.phpt deleted file mode 100755 index 8a14a52fe8..0000000000 --- a/ext/spl/tests/forward.phpt +++ /dev/null @@ -1,138 +0,0 @@ ---TEST-- -SPL: forward ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php -class c implements spl_forward_assoc { - - public $max = 3; - public $num = 0; - - function current() { - echo __METHOD__ . "\n"; - return $this->num; - } - function next() { - echo __METHOD__ . "\n"; - $this->num++; - } - function hasMore() { - echo __METHOD__ . "\n"; - return $this->num < $this->max; - } - function key() { - echo __METHOD__ . "\n"; - switch($this->num) { - case 0: return "1st"; - case 1: return "2nd"; - case 2: return "3rd"; - default: return "???"; - } - } -} - -$i = new c(); - -$implements = class_implements($i); -asort($implements); -$c_info = array(get_class($i) => array('inheits' => class_parents($i), 'implements' => $implements)); -print_r($c_info); -$methods = get_class_methods("spl_forward_assoc"); -sort($methods); -print_r($methods); -$methods = get_class_methods($i); -sort($methods); -print_r($methods); - - -echo "1st try\n"; -foreach($i as $w) { - echo "object:$w\n"; -} - -echo "2nd try\n"; - -foreach($i as $v => $w) { - echo "object:$v=>$w\n"; -} - -echo "3rd try\n"; -$i->num = 0; - -foreach($i as $v => $w) { - echo "object:$v=>$w\n"; -} - -print "Done\n"; -?> ---EXPECT-- -Array -( - [c] => Array - ( - [inheits] => Array - ( - ) - - [implements] => Array - ( - [spl_assoc] => spl_assoc - [spl_forward] => spl_forward - [spl_forward_assoc] => spl_forward_assoc - ) - - ) - -) -Array -( - [0] => current - [1] => hasMore - [2] => key - [3] => next -) -Array -( - [0] => current - [1] => hasMore - [2] => key - [3] => next -) -1st try -c::hasMore -c::current -c::key -object:0 -c::next -c::hasMore -c::current -c::key -object:1 -c::next -c::hasMore -c::current -c::key -object:2 -c::next -c::hasMore -2nd try -c::hasMore -3rd try -c::hasMore -c::current -c::key -object:1st=>0 -c::next -c::hasMore -c::current -c::key -object:2nd=>1 -c::next -c::hasMore -c::current -c::key -object:3rd=>2 -c::next -c::hasMore -Done diff --git a/ext/spl/tests/sequence.phpt b/ext/spl/tests/sequence.phpt deleted file mode 100755 index 34ea7fd8d5..0000000000 --- a/ext/spl/tests/sequence.phpt +++ /dev/null @@ -1,143 +0,0 @@ ---TEST-- -SPL: sequence ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php -class c implements spl_iterator { - - public $max = 3; - - function newIterator() { - echo __METHOD__ . "\n"; - return new c_iter($this); - } -} - -class c_iter implements spl_sequence_assoc { - - private $obj; - private $num = 0; - - function __construct($obj) { - $this->obj = $obj; - } - function rewind() { - echo __METHOD__ . "\n"; - $this->num = 0; - } - function current() { - echo __METHOD__ . "\n"; - return $this->num; - } - function next() { - echo __METHOD__ . "\n"; - $this->num++; - } - function hasMore() { - echo __METHOD__ . "\n"; - return $this->num < $this->obj->max; - } - function key() { - echo __METHOD__ . "\n"; - switch($this->num) { - case 0: return "1st"; - case 1: return "2nd"; - case 2: return "3rd"; - default: return "???"; - } - } -} - -$t = new c(); -$i = $t->newIterator(); - -$implements_t = class_implements($t); -asort($implements_t); -$implements_i = class_implements($i); -asort($implements_i); - -$c_info = array(get_class($t) => array('inheits' => class_parents($t), 'implements' => $implements_t), - get_class($i) => array('inheits' => class_parents($i), 'implements' => $implements_i)); -print_r($c_info); - -foreach($i as $w) { - echo "object:$w\n"; -} - -foreach($i as $v => $w) { - echo "object:$v=>$w\n"; -} - -print "Done\n"; -?> ---EXPECT-- -c::newIterator -Array -( - [c] => Array - ( - [inheits] => Array - ( - ) - - [implements] => Array - ( - [spl_iterator] => spl_iterator - ) - - ) - - [c_iter] => Array - ( - [inheits] => Array - ( - ) - - [implements] => Array - ( - [spl_assoc] => spl_assoc - [spl_forward] => spl_forward - [spl_forward_assoc] => spl_forward_assoc - [spl_sequence] => spl_sequence - [spl_sequence_assoc] => spl_sequence_assoc - ) - - ) - -) -c_iter::rewind -c_iter::hasMore -c_iter::current -c_iter::key -object:0 -c_iter::next -c_iter::hasMore -c_iter::current -c_iter::key -object:1 -c_iter::next -c_iter::hasMore -c_iter::current -c_iter::key -object:2 -c_iter::next -c_iter::hasMore -c_iter::rewind -c_iter::hasMore -c_iter::current -c_iter::key -object:1st=>0 -c_iter::next -c_iter::hasMore -c_iter::current -c_iter::key -object:2nd=>1 -c_iter::next -c_iter::hasMore -c_iter::current -c_iter::key -object:3rd=>2 -c_iter::next -c_iter::hasMore -Done
\ No newline at end of file |