Annotation of embedaddon/php/ext/mbstring/tests/mb_strrpos_variation1.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test mb_strrpos() function : usage variations - pass different data types to $haystack arg
        !             3: --SKIPIF--
        !             4: <?php
        !             5: extension_loaded('mbstring') or die('skip');
        !             6: function_exists('mb_strrpos') or die("skip mb_strrpos() is not available in this build");
        !             7: ?>
        !             8: --FILE--
        !             9: <?php
        !            10: /* Prototype  : int mb_strrpos(string $haystack, string $needle [, int $offset [, string $encoding]])
        !            11:  * Description: Find position of last occurrence of a string within another 
        !            12:  * Source code: ext/mbstring/mbstring.c
        !            13:  */
        !            14: 
        !            15: /*
        !            16:  * Pass mb_strrpos() different data types as $haystack argument to test behaviour
        !            17:  */
        !            18: 
        !            19: echo "*** Testing mb_strrpos() : usage variations ***\n";
        !            20: 
        !            21: // Initialise function arguments not being substituted
        !            22: $needle = b'world';
        !            23: $offset = 0;
        !            24: $encoding = 'utf-8';
        !            25: 
        !            26: //get an unset variable
        !            27: $unset_var = 10;
        !            28: unset ($unset_var);
        !            29: 
        !            30: // get a class
        !            31: class classA
        !            32: {
        !            33:   public function __toString() {
        !            34:     return b"hello, world";
        !            35:   }
        !            36: }
        !            37: 
        !            38: // heredoc string
        !            39: $heredoc = b<<<EOT
        !            40: hello, world
        !            41: EOT;
        !            42: 
        !            43: // get a resource variable
        !            44: $fp = fopen(__FILE__, "r");
        !            45: 
        !            46: // unexpected values to be passed to $haystack argument
        !            47: $inputs = array(
        !            48: 
        !            49:        // int data
        !            50: /*1*/  0,
        !            51:        1,
        !            52:        12345,
        !            53:        -2345,
        !            54: 
        !            55:        // float data
        !            56: /*5*/  10.5,
        !            57:        -10.5,
        !            58:        12.3456789000e10,
        !            59:        12.3456789000E-10,
        !            60:        .5,
        !            61: 
        !            62:        // null data
        !            63: /*10*/ NULL,
        !            64:        null,
        !            65: 
        !            66:        // boolean data
        !            67: /*12*/ true,
        !            68:        false,
        !            69:        TRUE,
        !            70:        FALSE,
        !            71:        
        !            72:        // empty data
        !            73: /*16*/ "",
        !            74:        '',
        !            75: 
        !            76:        // string data
        !            77: /*18*/ b"hello, world",
        !            78:        b'hello, world',
        !            79:        $heredoc,
        !            80:        
        !            81:        // object data
        !            82: /*21*/ new classA(),
        !            83: 
        !            84:        // undefined data
        !            85: /*22*/ @$undefined_var,
        !            86: 
        !            87:        // unset data
        !            88: /*23*/ @$unset_var,
        !            89: 
        !            90:        // resource variable
        !            91: /*24*/ $fp
        !            92: );
        !            93: 
        !            94: // loop through each element of $inputs to check the behavior of mb_strrpos()
        !            95: $iterator = 1;
        !            96: foreach($inputs as $input) {
        !            97:   echo "\n-- Iteration $iterator --\n";
        !            98:   var_dump( mb_strrpos($input, $needle, $offset, $encoding));
        !            99:   $iterator++;
        !           100: };
        !           101: 
        !           102: echo "Done";
        !           103: ?>
        !           104: 
        !           105: --EXPECTF--
        !           106: *** Testing mb_strrpos() : usage variations ***
        !           107: 
        !           108: -- Iteration 1 --
        !           109: bool(false)
        !           110: 
        !           111: -- Iteration 2 --
        !           112: bool(false)
        !           113: 
        !           114: -- Iteration 3 --
        !           115: bool(false)
        !           116: 
        !           117: -- Iteration 4 --
        !           118: bool(false)
        !           119: 
        !           120: -- Iteration 5 --
        !           121: bool(false)
        !           122: 
        !           123: -- Iteration 6 --
        !           124: bool(false)
        !           125: 
        !           126: -- Iteration 7 --
        !           127: bool(false)
        !           128: 
        !           129: -- Iteration 8 --
        !           130: bool(false)
        !           131: 
        !           132: -- Iteration 9 --
        !           133: bool(false)
        !           134: 
        !           135: -- Iteration 10 --
        !           136: bool(false)
        !           137: 
        !           138: -- Iteration 11 --
        !           139: bool(false)
        !           140: 
        !           141: -- Iteration 12 --
        !           142: bool(false)
        !           143: 
        !           144: -- Iteration 13 --
        !           145: bool(false)
        !           146: 
        !           147: -- Iteration 14 --
        !           148: bool(false)
        !           149: 
        !           150: -- Iteration 15 --
        !           151: bool(false)
        !           152: 
        !           153: -- Iteration 16 --
        !           154: bool(false)
        !           155: 
        !           156: -- Iteration 17 --
        !           157: bool(false)
        !           158: 
        !           159: -- Iteration 18 --
        !           160: int(7)
        !           161: 
        !           162: -- Iteration 19 --
        !           163: int(7)
        !           164: 
        !           165: -- Iteration 20 --
        !           166: int(7)
        !           167: 
        !           168: -- Iteration 21 --
        !           169: int(7)
        !           170: 
        !           171: -- Iteration 22 --
        !           172: bool(false)
        !           173: 
        !           174: -- Iteration 23 --
        !           175: bool(false)
        !           176: 
        !           177: -- Iteration 24 --
        !           178: 
        !           179: Warning: mb_strrpos() expects parameter 1 to be string, resource given in %s on line %d
        !           180: bool(false)
        !           181: Done

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