Annotation of embedaddon/php/ext/standard/tests/strings/chop_variation2.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test chop() function : usage variations  - unexpected values for charlist argument
        !             3: --FILE--
        !             4: <?php
        !             5: /* Prototype  : string chop ( string $str [, string $charlist] )
        !             6:  * Description: Strip whitespace (or other characters) from the end of a string
        !             7:  * Source code: ext/standard/string.c
        !             8: */
        !             9: 
        !            10: /*
        !            11:  * Testing chop() : with different unexpected values for charlist argument passes to the function
        !            12: */
        !            13: 
        !            14: echo "*** Testing chop() : with different unexpected values for charlist argument ***\n";
        !            15: // initialize all required variables
        !            16: $str = 'hello world12345 ';
        !            17: 
        !            18: // get an unset variable
        !            19: $unset_var = 'string_val';
        !            20: unset($unset_var);
        !            21: 
        !            22: // declaring class
        !            23: class sample  {
        !            24:   public function __toString()  {
        !            25:   return "@# $%12345";
        !            26:   }
        !            27: }
        !            28: 
        !            29: // defining a resource
        !            30: $file_handle = fopen(__FILE__, 'r');
        !            31: 
        !            32: // array with different values
        !            33: $values =  array (
        !            34: 
        !            35:   // integer values
        !            36:   0,
        !            37:   1,
        !            38:   12345,
        !            39:   -2345,
        !            40: 
        !            41:   // float values
        !            42:   10.5,
        !            43:   -10.5,
        !            44:   10.1234567e10,
        !            45:   10.7654321E-10,
        !            46:   .5,
        !            47: 
        !            48:   // array values
        !            49:   array(),
        !            50:   array(0),
        !            51:   array(1),
        !            52:   array(1, 2),
        !            53:   array('color' => 'red', 'item' => 'pen'),
        !            54: 
        !            55:   // boolean values
        !            56:   true,
        !            57:   false,
        !            58:   TRUE,
        !            59:   FALSE,
        !            60: 
        !            61:   // objects
        !            62:   new sample(),
        !            63: 
        !            64:   // empty string
        !            65:   "",
        !            66:   '',
        !            67: 
        !            68:   // null values
        !            69:   NULL,
        !            70:   null,
        !            71: 
        !            72:   // resource
        !            73:   $file_handle,
        !            74:   
        !            75:   // undefined variable
        !            76:   $undefined_var,
        !            77: 
        !            78:   // unset variable
        !            79:   $unset_var
        !            80:   
        !            81: );
        !            82: 
        !            83: 
        !            84: // loop through each element of the array and check the working of chop()
        !            85: // when $charlist arugment is supplied with different values
        !            86: 
        !            87: echo "\n--- Testing chop() by supplying different values for 'charlist' argument ---\n";
        !            88: $counter = 1;
        !            89: for($index = 0; $index < count($values); $index ++) {
        !            90:   echo "-- Iteration $counter --\n";
        !            91:   $charlist = $values [$index];
        !            92: 
        !            93:   var_dump( chop($str, $charlist) );
        !            94: 
        !            95:   $counter ++;
        !            96: }
        !            97: 
        !            98: // closing the resource
        !            99: fclose($file_handle);
        !           100: 
        !           101: echo "Done\n";
        !           102: ?>
        !           103: --EXPECTF--
        !           104: *** Testing chop() : with different unexpected values for charlist argument ***
        !           105: 
        !           106: Notice: Undefined variable: undefined_var in %s on line %d
        !           107: 
        !           108: Notice: Undefined variable: unset_var in %s on line %d
        !           109: 
        !           110: --- Testing chop() by supplying different values for 'charlist' argument ---
        !           111: -- Iteration 1 --
        !           112: string(17) "hello world12345 "
        !           113: -- Iteration 2 --
        !           114: string(17) "hello world12345 "
        !           115: -- Iteration 3 --
        !           116: string(17) "hello world12345 "
        !           117: -- Iteration 4 --
        !           118: string(17) "hello world12345 "
        !           119: -- Iteration 5 --
        !           120: string(17) "hello world12345 "
        !           121: -- Iteration 6 --
        !           122: string(17) "hello world12345 "
        !           123: -- Iteration 7 --
        !           124: string(17) "hello world12345 "
        !           125: -- Iteration 8 --
        !           126: string(17) "hello world12345 "
        !           127: -- Iteration 9 --
        !           128: string(17) "hello world12345 "
        !           129: -- Iteration 10 --
        !           130: 
        !           131: Warning: chop() expects parameter 2 to be string, array given in %s on line %d
        !           132: NULL
        !           133: -- Iteration 11 --
        !           134: 
        !           135: Warning: chop() expects parameter 2 to be string, array given in %s on line %d
        !           136: NULL
        !           137: -- Iteration 12 --
        !           138: 
        !           139: Warning: chop() expects parameter 2 to be string, array given in %s on line %d
        !           140: NULL
        !           141: -- Iteration 13 --
        !           142: 
        !           143: Warning: chop() expects parameter 2 to be string, array given in %s on line %d
        !           144: NULL
        !           145: -- Iteration 14 --
        !           146: 
        !           147: Warning: chop() expects parameter 2 to be string, array given in %s on line %d
        !           148: NULL
        !           149: -- Iteration 15 --
        !           150: string(17) "hello world12345 "
        !           151: -- Iteration 16 --
        !           152: string(17) "hello world12345 "
        !           153: -- Iteration 17 --
        !           154: string(17) "hello world12345 "
        !           155: -- Iteration 18 --
        !           156: string(17) "hello world12345 "
        !           157: -- Iteration 19 --
        !           158: string(11) "hello world"
        !           159: -- Iteration 20 --
        !           160: string(17) "hello world12345 "
        !           161: -- Iteration 21 --
        !           162: string(17) "hello world12345 "
        !           163: -- Iteration 22 --
        !           164: string(17) "hello world12345 "
        !           165: -- Iteration 23 --
        !           166: string(17) "hello world12345 "
        !           167: -- Iteration 24 --
        !           168: 
        !           169: Warning: chop() expects parameter 2 to be string, resource given in %s on line %d
        !           170: NULL
        !           171: -- Iteration 25 --
        !           172: string(17) "hello world12345 "
        !           173: -- Iteration 26 --
        !           174: string(17) "hello world12345 "
        !           175: Done

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