Annotation of embedaddon/php/tests/classes/interface_implemented.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: ZE2 An interface is inherited
        !             3: --SKIPIF--
        !             4: <?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
        !             5: --FILE--
        !             6: <?php
        !             7: 
        !             8: interface if_a {
        !             9:        function f_a();
        !            10: }
        !            11:        
        !            12: interface if_b extends if_a {
        !            13:        function f_b();
        !            14: }
        !            15: 
        !            16: class base {
        !            17:        function _is_a($sub) {
        !            18:                echo 'is_a('.get_class($this).', '.$sub.') = '.(($this instanceof $sub) ? 'yes' : 'no')."\n";
        !            19:        }
        !            20:        function test() {
        !            21:                echo $this->_is_a('base');
        !            22:                echo $this->_is_a('derived_a');
        !            23:                echo $this->_is_a('derived_b');
        !            24:                echo $this->_is_a('derived_c');
        !            25:                echo $this->_is_a('derived_d');
        !            26:                echo $this->_is_a('if_a');
        !            27:                echo $this->_is_a('if_b');
        !            28:                echo "\n";
        !            29:        }
        !            30: }
        !            31: 
        !            32: class derived_a extends base implements if_a {
        !            33:        function f_a() {}
        !            34: }
        !            35: 
        !            36: class derived_b extends base implements if_a, if_b {
        !            37:        function f_a() {}
        !            38:        function f_b() {}
        !            39: }
        !            40: 
        !            41: class derived_c extends derived_a implements if_b {
        !            42:        function f_b() {}
        !            43: }
        !            44: 
        !            45: class derived_d extends derived_c {
        !            46: }
        !            47: 
        !            48: $t = new base();
        !            49: $t->test();
        !            50: 
        !            51: $t = new derived_a();
        !            52: $t->test();
        !            53: 
        !            54: $t = new derived_b();
        !            55: $t->test();
        !            56: 
        !            57: $t = new derived_c();
        !            58: $t->test();
        !            59: 
        !            60: $t = new derived_d();
        !            61: $t->test();
        !            62: 
        !            63: ?>
        !            64: --EXPECTF--
        !            65: is_a(base, base) = yes
        !            66: is_a(base, derived_a) = no
        !            67: is_a(base, derived_b) = no
        !            68: is_a(base, derived_c) = no
        !            69: is_a(base, derived_d) = no
        !            70: is_a(base, if_a) = no
        !            71: is_a(base, if_b) = no
        !            72: 
        !            73: is_a(derived_a, base) = yes
        !            74: is_a(derived_a, derived_a) = yes
        !            75: is_a(derived_a, derived_b) = no
        !            76: is_a(derived_a, derived_c) = no
        !            77: is_a(derived_a, derived_d) = no
        !            78: is_a(derived_a, if_a) = yes
        !            79: is_a(derived_a, if_b) = no
        !            80: 
        !            81: is_a(derived_b, base) = yes
        !            82: is_a(derived_b, derived_a) = no
        !            83: is_a(derived_b, derived_b) = yes
        !            84: is_a(derived_b, derived_c) = no
        !            85: is_a(derived_b, derived_d) = no
        !            86: is_a(derived_b, if_a) = yes
        !            87: is_a(derived_b, if_b) = yes
        !            88: 
        !            89: is_a(derived_c, base) = yes
        !            90: is_a(derived_c, derived_a) = yes
        !            91: is_a(derived_c, derived_b) = no
        !            92: is_a(derived_c, derived_c) = yes
        !            93: is_a(derived_c, derived_d) = no
        !            94: is_a(derived_c, if_a) = yes
        !            95: is_a(derived_c, if_b) = yes
        !            96: 
        !            97: is_a(derived_d, base) = yes
        !            98: is_a(derived_d, derived_a) = yes
        !            99: is_a(derived_d, derived_b) = no
        !           100: is_a(derived_d, derived_c) = yes
        !           101: is_a(derived_d, derived_d) = yes
        !           102: is_a(derived_d, if_a) = yes
        !           103: is_a(derived_d, if_b) = yes

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