Annotation of embedaddon/php/tests/lang/foreachLoopObjects.005.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Foreach loop tests - removing properties before and after the current property during the loop.
                      3: --FILE--
                      4: <?php
                      5: 
                      6: class C {
                      7:        public $a = "Original a";
                      8:        public $b = "Original b";
                      9:        public $c = "Original c";
                     10:        public $d = "Original d";
                     11:        public $e = "Original e";
                     12: }
                     13: 
                     14: echo "\nRemoving properties before the current element from an iterated object.\n";
                     15: $obj = new C;
                     16: $count=0;
                     17: foreach ($obj as $v) {
                     18:        if ($v==$obj->a) {
                     19:                unset($obj->c); 
                     20:        }
                     21:        var_dump($v);
                     22:        if (++$count>10) {
                     23:                echo "Loop detected.\n";
                     24:                break;
                     25:        }               
                     26: }
                     27: var_dump($obj);
                     28: 
                     29: echo "\nRemoving properties before the current element from an iterated object.\n";
                     30: $obj = new C;
                     31: foreach ($obj as $v) {
                     32:        if ($v==$obj->b) {
                     33:                unset($obj->a); 
                     34:        }
                     35:        var_dump($v);
                     36:        if (++$count>10) {
                     37:                echo "Loop detected.\n";
                     38:                break;
                     39:        }       
                     40: }
                     41: var_dump($obj);
                     42: 
                     43: 
                     44: ?>
                     45: --EXPECTF--
                     46: 
                     47: Removing properties before the current element from an iterated object.
                     48: string(10) "Original a"
                     49: string(10) "Original b"
                     50: string(10) "Original d"
                     51: string(10) "Original e"
                     52: object(C)#%d (4) {
                     53:   ["a"]=>
                     54:   string(10) "Original a"
                     55:   ["b"]=>
                     56:   string(10) "Original b"
                     57:   ["d"]=>
                     58:   string(10) "Original d"
                     59:   ["e"]=>
                     60:   string(10) "Original e"
                     61: }
                     62: 
                     63: Removing properties before the current element from an iterated object.
                     64: string(10) "Original a"
                     65: string(10) "Original b"
                     66: string(10) "Original c"
                     67: string(10) "Original d"
                     68: string(10) "Original e"
                     69: object(C)#%d (4) {
                     70:   ["b"]=>
                     71:   string(10) "Original b"
                     72:   ["c"]=>
                     73:   string(10) "Original c"
                     74:   ["d"]=>
                     75:   string(10) "Original d"
                     76:   ["e"]=>
                     77:   string(10) "Original e"
                     78: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>