Annotation of embedaddon/php/ext/standard/tests/file/umask_variation3.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test umask() function : usage variation
        !             3: --CREDITS--
        !             4: Dave Kelsey <d_kelsey@uk.ibm.com>
        !             5: --SKIPIF--
        !             6: <?php
        !             7: if (substr(PHP_OS, 0, 3) == 'WIN') {
        !             8:     die('skip.. only for Non Windows');
        !             9: }
        !            10: ?>
        !            11: --FILE--
        !            12: <?php
        !            13: /* Prototype  : int umask([int mask])
        !            14:  * Description: Return or change the umask 
        !            15:  * Source code: ext/standard/file.c
        !            16:  * Alias to functions: 
        !            17:  */
        !            18: 
        !            19: echo "*** Testing umask() : usage variation ***\n";
        !            20: 
        !            21: // Define error handler
        !            22: function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
        !            23:        if (error_reporting() != 0) {
        !            24:                // report non-silenced errors
        !            25:                echo "Error: $err_no - $err_msg, $filename($linenum)\n";
        !            26:        }
        !            27: }
        !            28: set_error_handler('test_error_handler');
        !            29: 
        !            30: // Initialise function arguments not being substituted (if any)
        !            31: 
        !            32: //get an unset variable
        !            33: $unset_var = 10;
        !            34: unset ($unset_var);
        !            35: 
        !            36: // define some classes
        !            37: class classWithToString
        !            38: {
        !            39:        public function __toString() {
        !            40:                return "Class A object";
        !            41:        }
        !            42: }
        !            43: 
        !            44: class classWithoutToString
        !            45: {
        !            46: }
        !            47: 
        !            48: // heredoc string
        !            49: $heredoc = <<<EOT
        !            50: hello world
        !            51: EOT;
        !            52: 
        !            53: // add arrays
        !            54: $index_array = array (1, 2, 3);
        !            55: $assoc_array = array ('one' => 1, 'two' => 2);
        !            56: 
        !            57: //array of values to iterate over
        !            58: $inputs = array(
        !            59:       //out of boundary integers
        !            60:       'int -100' => -100,
        !            61:       'int 99999' => 99999,
        !            62: 
        !            63:       // float data
        !            64:       'float 10.5' => 10.5,
        !            65:       'float -10.5' => -10.5,
        !            66:       'float 12.3456789000e10' => 12.3456789000e10,
        !            67:       //'float -12.3456789000e10' => -12.3456789000e10, different in p8
        !            68:       'float .5' => .5,
        !            69: 
        !            70:       // array data
        !            71:       'empty array' => array(),
        !            72:       'int indexed array' => $index_array,
        !            73:       'associative array' => $assoc_array,
        !            74:       'nested arrays' => array('foo', $index_array, $assoc_array),
        !            75: 
        !            76:       // null data
        !            77:       'uppercase NULL' => NULL,
        !            78:       'lowercase null' => null,
        !            79: 
        !            80:       // boolean data
        !            81:       'lowercase true' => true,
        !            82:       'lowercase false' =>false,
        !            83:       'uppercase TRUE' =>TRUE,
        !            84:       'uppercase FALSE' =>FALSE,
        !            85: 
        !            86:       // empty data
        !            87:       'empty string DQ' => "",
        !            88:       'empty string SQ' => '',
        !            89: 
        !            90:       // string data
        !            91:       'string DQ' => "string",
        !            92:       'string SQ' => 'string',
        !            93:       'mixed case string' => "sTrInG",
        !            94:       'heredoc' => $heredoc,
        !            95: 
        !            96:       // object data
        !            97:       'instance of classWithToString' => new classWithToString(),
        !            98:       'instance of classWithoutToString' => new classWithoutToString(),
        !            99: 
        !           100:       // undefined data
        !           101:       'undefined var' => @$undefined_var,
        !           102: 
        !           103:       // unset data
        !           104:       'unset var' => @$unset_var,
        !           105: );
        !           106: 
        !           107: // loop through each element of the array for mask
        !           108: 
        !           109: foreach($inputs as $key =>$value) {
        !           110:       echo "\n--$key--\n";
        !           111:       umask(0);
        !           112:       var_dump(umask($value));
        !           113:       var_dump( umask());
        !           114: };
        !           115: 
        !           116: ?>
        !           117: ===DONE===
        !           118: --EXPECTF--
        !           119: *** Testing umask() : usage variation ***
        !           120: 
        !           121: --int -100--
        !           122: int(0)
        !           123: int(412)
        !           124: 
        !           125: --int 99999--
        !           126: int(0)
        !           127: int(159)
        !           128: 
        !           129: --float 10.5--
        !           130: int(0)
        !           131: int(10)
        !           132: 
        !           133: --float -10.5--
        !           134: int(0)
        !           135: int(502)
        !           136: 
        !           137: --float 12.3456789000e10--
        !           138: int(0)
        !           139: int(%d)
        !           140: 
        !           141: --float .5--
        !           142: int(0)
        !           143: int(0)
        !           144: 
        !           145: --empty array--
        !           146: Error: 2 - umask() expects parameter 1 to be long, array given, %s(%d)
        !           147: bool(false)
        !           148: int(63)
        !           149: 
        !           150: --int indexed array--
        !           151: Error: 2 - umask() expects parameter 1 to be long, array given, %s(%d)
        !           152: bool(false)
        !           153: int(63)
        !           154: 
        !           155: --associative array--
        !           156: Error: 2 - umask() expects parameter 1 to be long, array given, %s(%d)
        !           157: bool(false)
        !           158: int(63)
        !           159: 
        !           160: --nested arrays--
        !           161: Error: 2 - umask() expects parameter 1 to be long, array given, %s(%d)
        !           162: bool(false)
        !           163: int(63)
        !           164: 
        !           165: --uppercase NULL--
        !           166: int(0)
        !           167: int(0)
        !           168: 
        !           169: --lowercase null--
        !           170: int(0)
        !           171: int(0)
        !           172: 
        !           173: --lowercase true--
        !           174: int(0)
        !           175: int(1)
        !           176: 
        !           177: --lowercase false--
        !           178: int(0)
        !           179: int(0)
        !           180: 
        !           181: --uppercase TRUE--
        !           182: int(0)
        !           183: int(1)
        !           184: 
        !           185: --uppercase FALSE--
        !           186: int(0)
        !           187: int(0)
        !           188: 
        !           189: --empty string DQ--
        !           190: Error: 2 - umask() expects parameter 1 to be long, string given, %s(%d)
        !           191: bool(false)
        !           192: int(63)
        !           193: 
        !           194: --empty string SQ--
        !           195: Error: 2 - umask() expects parameter 1 to be long, string given, %s(%d)
        !           196: bool(false)
        !           197: int(63)
        !           198: 
        !           199: --string DQ--
        !           200: Error: 2 - umask() expects parameter 1 to be long, string given, %s(%d)
        !           201: bool(false)
        !           202: int(63)
        !           203: 
        !           204: --string SQ--
        !           205: Error: 2 - umask() expects parameter 1 to be long, string given, %s(%d)
        !           206: bool(false)
        !           207: int(63)
        !           208: 
        !           209: --mixed case string--
        !           210: Error: 2 - umask() expects parameter 1 to be long, string given, %s(%d)
        !           211: bool(false)
        !           212: int(63)
        !           213: 
        !           214: --heredoc--
        !           215: Error: 2 - umask() expects parameter 1 to be long, string given, %s(%d)
        !           216: bool(false)
        !           217: int(63)
        !           218: 
        !           219: --instance of classWithToString--
        !           220: Error: 2 - umask() expects parameter 1 to be long, object given, %s(%d)
        !           221: bool(false)
        !           222: int(63)
        !           223: 
        !           224: --instance of classWithoutToString--
        !           225: Error: 2 - umask() expects parameter 1 to be long, object given, %s(%d)
        !           226: bool(false)
        !           227: int(63)
        !           228: 
        !           229: --undefined var--
        !           230: int(0)
        !           231: int(0)
        !           232: 
        !           233: --unset var--
        !           234: int(0)
        !           235: int(0)
        !           236: ===DONE===
        !           237: 

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