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

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

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