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

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

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