Annotation of embedaddon/php/ext/standard/tests/math/decbin_variation1.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test decbin() function : usage variations - different data types as $number arg
        !             3: --INI--
        !             4: precision=14
        !             5: --SKIPIF--
        !             6: <?php
        !             7: if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
        !             8: ?>
        !             9: --FILE--
        !            10: <?php
        !            11: /* Prototype  : string decbin  ( int $number  )
        !            12:  * Description: Decimal to binary.
        !            13:  * Source code: ext/standard/math.c
        !            14:  */
        !            15: 
        !            16: echo "*** Testing decbin() : usage variations ***\n";
        !            17: //get an unset variable
        !            18: $unset_var = 10;
        !            19: unset ($unset_var);
        !            20: 
        !            21: // heredoc string
        !            22: $heredoc = <<<EOT
        !            23: abc
        !            24: xyz
        !            25: EOT;
        !            26: 
        !            27: // get a class
        !            28: class classA
        !            29: {
        !            30: }
        !            31: 
        !            32: // get a resource variable
        !            33: $fp = fopen(__FILE__, "r");
        !            34: 
        !            35: $inputs = array(
        !            36:        // int data
        !            37: /*1*/  0,
        !            38:        1,
        !            39:        12345,
        !            40:        -2345,
        !            41:        4294967295,  // largest decimal  
        !            42:        4294967296, 
        !            43: 
        !            44:        // float data
        !            45: /*7*/  10.5,
        !            46:        -10.5,
        !            47:        12.3456789000e10,
        !            48:        12.3456789000E-10,
        !            49:        .5,
        !            50: 
        !            51:        // null data
        !            52: /*12*/ NULL,
        !            53:        null,
        !            54: 
        !            55:        // boolean data
        !            56: /*14*/ true,
        !            57:        false,
        !            58:        TRUE,
        !            59:        FALSE,
        !            60:        
        !            61:        // empty data
        !            62: /*18*/ "",
        !            63:        '',
        !            64:        array(),
        !            65: 
        !            66:        // string data
        !            67: /*21*/ "abcxyz",
        !            68:        'abcxyz',
        !            69:        $heredoc,
        !            70: 
        !            71:        // object data
        !            72: /*24*/ new classA(),          
        !            73:        
        !            74:        // undefined data
        !            75: /*25*/ @$undefined_var,
        !            76: 
        !            77:        // unset data
        !            78: /*26*/ @$unset_var,
        !            79: 
        !            80:        // resource variable
        !            81: /*27*/ $fp
        !            82: );
        !            83: 
        !            84: // loop through each element of $inputs to check the behaviour of decbin()
        !            85: $iterator = 1;
        !            86: foreach($inputs as $input) {
        !            87:        echo "\n-- Iteration $iterator --\n";
        !            88:        var_dump(decbin($input));
        !            89:        $iterator++;
        !            90: };
        !            91: fclose($fp);
        !            92: ?>
        !            93: ===Done===
        !            94: --EXPECTF--
        !            95: *** Testing decbin() : usage variations ***
        !            96: 
        !            97: -- Iteration 1 --
        !            98: string(1) "0"
        !            99: 
        !           100: -- Iteration 2 --
        !           101: string(1) "1"
        !           102: 
        !           103: -- Iteration 3 --
        !           104: string(14) "11000000111001"
        !           105: 
        !           106: -- Iteration 4 --
        !           107: string(32) "11111111111111111111011011010111"
        !           108: 
        !           109: -- Iteration 5 --
        !           110: string(32) "11111111111111111111111111111111"
        !           111: 
        !           112: -- Iteration 6 --
        !           113: string(1) "0"
        !           114: 
        !           115: -- Iteration 7 --
        !           116: string(4) "1010"
        !           117: 
        !           118: -- Iteration 8 --
        !           119: string(32) "11111111111111111111111111110110"
        !           120: 
        !           121: -- Iteration 9 --
        !           122: string(32) "10111110100110010001101000001000"
        !           123: 
        !           124: -- Iteration 10 --
        !           125: string(1) "0"
        !           126: 
        !           127: -- Iteration 11 --
        !           128: string(1) "0"
        !           129: 
        !           130: -- Iteration 12 --
        !           131: string(1) "0"
        !           132: 
        !           133: -- Iteration 13 --
        !           134: string(1) "0"
        !           135: 
        !           136: -- Iteration 14 --
        !           137: string(1) "1"
        !           138: 
        !           139: -- Iteration 15 --
        !           140: string(1) "0"
        !           141: 
        !           142: -- Iteration 16 --
        !           143: string(1) "1"
        !           144: 
        !           145: -- Iteration 17 --
        !           146: string(1) "0"
        !           147: 
        !           148: -- Iteration 18 --
        !           149: string(1) "0"
        !           150: 
        !           151: -- Iteration 19 --
        !           152: string(1) "0"
        !           153: 
        !           154: -- Iteration 20 --
        !           155: string(1) "0"
        !           156: 
        !           157: -- Iteration 21 --
        !           158: string(1) "0"
        !           159: 
        !           160: -- Iteration 22 --
        !           161: string(1) "0"
        !           162: 
        !           163: -- Iteration 23 --
        !           164: string(1) "0"
        !           165: 
        !           166: -- Iteration 24 --
        !           167: 
        !           168: Notice: Object of class classA could not be converted to int in %s on line %d
        !           169: string(1) "1"
        !           170: 
        !           171: -- Iteration 25 --
        !           172: string(1) "0"
        !           173: 
        !           174: -- Iteration 26 --
        !           175: string(1) "0"
        !           176: 
        !           177: -- Iteration 27 --
        !           178: string(%d) "%d"
        !           179: ===Done===

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