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

1.1     ! misho       1: --TEST--
        !             2: Test chr() function : usage variations - test values for $ascii argument
        !             3: --FILE--
        !             4: <?php
        !             5: 
        !             6: /* Prototype  : string chr  ( int $ascii  )
        !             7:  * Description: Return a specific character
        !             8:  * Source code: ext/standard/string.c
        !             9: */
        !            10: 
        !            11: echo "*** Testing chr() function: with unexpected inputs for 'ascii' argument ***\n";
        !            12: 
        !            13: //get an unset variable
        !            14: $unset_var = 'string_val';
        !            15: unset($unset_var);
        !            16: 
        !            17: //defining a class
        !            18: class sample  {
        !            19:   public function __toString() {
        !            20:     return "sample object";
        !            21:   } 
        !            22: }
        !            23: 
        !            24: //getting the resource
        !            25: $file_handle = fopen(__FILE__, "r");
        !            26: 
        !            27: // array with different values for $input
        !            28: $inputs =  array (
        !            29: 
        !            30:                  // integer values
        !            31: /*1*/    0,
        !            32:                  1,
        !            33:                  255,
        !            34:                  256,
        !            35:                
        !            36:                  // float values
        !            37: /*5*/    10.5,
        !            38:                  -20.5,
        !            39:                  1.1234e6,
        !            40:                
        !            41:                  // array values
        !            42: /*8*/    array(),
        !            43:                  array(0),
        !            44:                  array(1, 2),
        !            45:                
        !            46:                  // boolean values
        !            47: /*11*/   true,
        !            48:                  false,
        !            49:                  TRUE,
        !            50:                  FALSE,
        !            51:                
        !            52:                  // null values
        !            53: /*15*/   NULL,
        !            54:                  null,
        !            55:                
        !            56:                  // objects
        !            57: /*17*/   new sample(),
        !            58:                
        !            59:                  // resource
        !            60: /*18*/   $file_handle,
        !            61:                
        !            62:                  // undefined variable
        !            63: /*19*/   @$undefined_var,
        !            64:                
        !            65:                  // unset variable
        !            66: /*20*/   @$unset_var
        !            67: );
        !            68: 
        !            69: // loop through with each element of the $inputs array to test chr() function
        !            70: $count = 1;
        !            71: foreach($inputs as $input) {
        !            72:   echo "-- Iteration $count --\n";
        !            73:   var_dump( bin2hex(chr($input)) );
        !            74:   $count ++;
        !            75: }
        !            76: 
        !            77: fclose($file_handle);  //closing the file handle
        !            78: 
        !            79: ?>
        !            80: ===DONE===
        !            81: --EXPECTF--
        !            82: *** Testing chr() function: with unexpected inputs for 'ascii' argument ***
        !            83: -- Iteration 1 --
        !            84: string(2) "00"
        !            85: -- Iteration 2 --
        !            86: string(2) "01"
        !            87: -- Iteration 3 --
        !            88: string(2) "ff"
        !            89: -- Iteration 4 --
        !            90: string(2) "00"
        !            91: -- Iteration 5 --
        !            92: string(2) "0a"
        !            93: -- Iteration 6 --
        !            94: string(2) "ec"
        !            95: -- Iteration 7 --
        !            96: string(2) "48"
        !            97: -- Iteration 8 --
        !            98: string(2) "00"
        !            99: -- Iteration 9 --
        !           100: string(2) "00"
        !           101: -- Iteration 10 --
        !           102: string(2) "00"
        !           103: -- Iteration 11 --
        !           104: string(2) "01"
        !           105: -- Iteration 12 --
        !           106: string(2) "00"
        !           107: -- Iteration 13 --
        !           108: string(2) "01"
        !           109: -- Iteration 14 --
        !           110: string(2) "00"
        !           111: -- Iteration 15 --
        !           112: string(2) "00"
        !           113: -- Iteration 16 --
        !           114: string(2) "00"
        !           115: -- Iteration 17 --
        !           116: string(2) "00"
        !           117: -- Iteration 18 --
        !           118: string(2) "00"
        !           119: -- Iteration 19 --
        !           120: string(2) "00"
        !           121: -- Iteration 20 --
        !           122: string(2) "00"
        !           123: ===DONE===

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