Annotation of embedaddon/php/ext/spl/tests/bug54384.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Bug #54384: Several SPL classes crash when the parent constructor is not called
        !             3: --FILE--
        !             4: <?php
        !             5: 
        !             6: function test($f) {
        !             7:        try {
        !             8:                $f();
        !             9:                echo "ran normally (unexpected)\n\n";
        !            10:        } catch (LogicException $e) {
        !            11:                echo "exception (expected)\n";
        !            12:        }
        !            13: }
        !            14: 
        !            15: echo "IteratorIterator... ";
        !            16: class IteratorIteratorTest extends IteratorIterator {
        !            17:     function __construct(){}
        !            18: }
        !            19: test( function() {
        !            20:        $o = new IteratorIteratorTest;
        !            21:        $o->rewind();
        !            22: } );
        !            23: 
        !            24: echo "FilterIterator... ";
        !            25: class FilterIteratorTest extends FilterIterator {
        !            26:     function __construct(){}
        !            27:     function accept(){}
        !            28: }
        !            29: test( function() {
        !            30:        $o = new FilterIteratorTest;
        !            31:        $o->rewind();
        !            32: } );
        !            33: 
        !            34: echo "RecursiveFilterIterator... ";
        !            35: class RecursiveFilterIteratorTest extends RecursiveFilterIterator {
        !            36:     function __construct(){}
        !            37:     function accept(){}
        !            38: }
        !            39: test( function() {
        !            40: $o = new RecursiveFilterIteratorTest;
        !            41: $o->hasChildren();
        !            42: } );
        !            43: 
        !            44: echo "ParentIterator... ";
        !            45: class ParentIteratorTest extends ParentIterator {
        !            46:     function __construct(){}
        !            47: }
        !            48: test ( function() {
        !            49: $o = new ParentIteratorTest;
        !            50: $o->accept();
        !            51: } );
        !            52: 
        !            53: echo "LimitIterator... ";
        !            54: class LimitIteratorTest extends LimitIterator {
        !            55:     function __construct(){}
        !            56: }
        !            57: test ( function() {
        !            58: $o = new LimitIteratorTest;
        !            59: $o->rewind();
        !            60: } );
        !            61: 
        !            62: echo "CachingIterator... ";
        !            63: class CachingIteratorTest extends CachingIterator {
        !            64:     function __construct(){}
        !            65: }
        !            66: test ( function() {
        !            67: $o = new CachingIteratorTest;
        !            68: $o->rewind();
        !            69: } );
        !            70: 
        !            71: echo "RecursiveCachingIterator... ";
        !            72: class RecursiveCachingIteratorTest extends RecursiveCachingIterator {
        !            73:     function __construct(){}
        !            74: }
        !            75: test ( function() {
        !            76: $o = new RecursiveCachingIteratorTest;
        !            77: $o->rewind();
        !            78: } );
        !            79: 
        !            80: echo "NoRewindIterator... ";
        !            81: class NoRewindIteratorTest extends NoRewindIterator {
        !            82:     function __construct(){}
        !            83: }
        !            84: test ( function() {
        !            85: $o = new NoRewindIteratorTest;
        !            86: $o->valid();
        !            87: } );
        !            88: 
        !            89: echo "RegexIterator... ";
        !            90: class RegexIteratorTest extends RegexIterator {
        !            91:     function __construct(){}
        !            92: }
        !            93: test ( function() {
        !            94: $o = new RegexIteratorTest;
        !            95: $o->rewind();
        !            96: } );
        !            97: 
        !            98: echo "RecursiveRegexIterator... ";
        !            99: class RecursiveRegexIteratorTest extends RecursiveRegexIterator {
        !           100:     function __construct(){}
        !           101: }
        !           102: test ( function() {
        !           103: $o = new RecursiveRegexIteratorTest;
        !           104: $o->hasChildren();
        !           105: } );
        !           106: 
        !           107: echo "GlobIterator... ";
        !           108: class GlobIteratorTest extends GlobIterator {
        !           109:     function __construct(){}
        !           110: }
        !           111: test ( function() {
        !           112: $o = new GlobIteratorTest;
        !           113: $o->count();
        !           114: } );
        !           115: 
        !           116: echo "SplFileObject... ";
        !           117: class SplFileObjectTest extends SplFileObject {
        !           118:     function __construct(){}
        !           119: }
        !           120: test ( function() {
        !           121: $o = new SplFileObjectTest;
        !           122: $o->rewind();
        !           123: } );
        !           124: 
        !           125: echo "SplTempFileObject... ";
        !           126: class SplTempFileObjectTest extends SplTempFileObject {
        !           127:     function __construct(){}
        !           128: }
        !           129: test ( function() {
        !           130: $o = new SplTempFileObjectTest;
        !           131: $o->rewind();
        !           132: } );
        !           133: 
        !           134: echo "AppendIterator... ";
        !           135: class AppendIteratorTest extends AppendIterator {
        !           136:     function __construct(){}
        !           137: }
        !           138: test ( function() {
        !           139: $o = new AppendIteratorTest;
        !           140: foreach ($o as $a) {
        !           141: echo $a,"\n";
        !           142: }
        !           143: } );
        !           144: 
        !           145: echo "InfiniteIterator... ";
        !           146: class InfiniteIteratorTest extends InfiniteIterator {
        !           147:     function __construct(){}
        !           148: }
        !           149: test ( function() {
        !           150: $o = new InfiniteIteratorTest;
        !           151: foreach ($o as $a) {
        !           152: echo $a,"\n";
        !           153: }
        !           154: } );
        !           155: 
        !           156: --EXPECT--
        !           157: IteratorIterator... exception (expected)
        !           158: FilterIterator... exception (expected)
        !           159: RecursiveFilterIterator... exception (expected)
        !           160: ParentIterator... exception (expected)
        !           161: LimitIterator... exception (expected)
        !           162: CachingIterator... exception (expected)
        !           163: RecursiveCachingIterator... exception (expected)
        !           164: NoRewindIterator... exception (expected)
        !           165: RegexIterator... exception (expected)
        !           166: RecursiveRegexIterator... exception (expected)
        !           167: GlobIterator... exception (expected)
        !           168: SplFileObject... exception (expected)
        !           169: SplTempFileObject... exception (expected)
        !           170: AppendIterator... exception (expected)
        !           171: InfiniteIterator... exception (expected)

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