Annotation of embedaddon/php/ext/standard/tests/math/pow_variation1.phpt, revision 1.1.1.1

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

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