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

1.1       misho       1: --TEST--
                      2: Test round() function : usage variations - different data types as $val argument
                      3: --INI--
                      4: precision=14
                      5: --FILE--
                      6: <?php
                      7: /* Prototype  : float round  ( float $val  [, int $precision  ] )
                      8:  * Description: Returns the rounded value of val  to specified precision (number of digits
                      9:  * after the decimal point)
                     10:  * Source code: ext/standard/math.c
                     11:  */
                     12: 
                     13: echo "*** Testing round() : usage variations ***\n";
                     14: 
                     15: //get an unset variable
                     16: $unset_var = 10;
                     17: unset ($unset_var);
                     18: 
                     19: // heredoc string
                     20: $heredoc = <<<EOT
                     21: abc
                     22: xyz
                     23: EOT;
                     24: 
                     25: // get a class
                     26: class classA
                     27: {
                     28: }
                     29: 
                     30: // get a resource variable
                     31: $fp = fopen(__FILE__, "r");
                     32: 
                     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 round()
                     82: $iterator = 1;
                     83: foreach($inputs as $input) {
                     84:        echo "\n-- Iteration $iterator --\n";
                     85:        var_dump(round($input, 14));
                     86:        $iterator++;
                     87: };
                     88: fclose($fp);
                     89: ?>
                     90: ===Done===
                     91: --EXPECTF--
                     92: *** Testing round() : usage variations ***
                     93: 
                     94: -- Iteration 1 --
                     95: float(0)
                     96: 
                     97: -- Iteration 2 --
                     98: float(1)
                     99: 
                    100: -- Iteration 3 --
                    101: float(12345)
                    102: 
                    103: -- Iteration 4 --
                    104: float(-2345)
                    105: 
                    106: -- Iteration 5 --
                    107: float(2147483647)
                    108: 
                    109: -- Iteration 6 --
                    110: float(10.5)
                    111: 
                    112: -- Iteration 7 --
                    113: float(-10.5)
                    114: 
                    115: -- Iteration 8 --
                    116: float(123456789000)
                    117: 
                    118: -- Iteration 9 --
                    119: float(1.23457E-9)
                    120: 
                    121: -- Iteration 10 --
                    122: float(0.5)
                    123: 
                    124: -- Iteration 11 --
                    125: float(0)
                    126: 
                    127: -- Iteration 12 --
                    128: float(0)
                    129: 
                    130: -- Iteration 13 --
                    131: float(1)
                    132: 
                    133: -- Iteration 14 --
                    134: float(0)
                    135: 
                    136: -- Iteration 15 --
                    137: float(1)
                    138: 
                    139: -- Iteration 16 --
                    140: float(0)
                    141: 
                    142: -- Iteration 17 --
                    143: float(0)
                    144: 
                    145: -- Iteration 18 --
                    146: float(0)
                    147: 
                    148: -- Iteration 19 --
                    149: bool(false)
                    150: 
                    151: -- Iteration 20 --
                    152: float(0)
                    153: 
                    154: -- Iteration 21 --
                    155: float(0)
                    156: 
                    157: -- Iteration 22 --
                    158: float(0)
                    159: 
                    160: -- Iteration 23 --
                    161: 
                    162: Notice: Object of class classA could not be converted to int in %s on line %d
                    163: float(1)
                    164: 
                    165: -- Iteration 24 --
                    166: float(0)
                    167: 
                    168: -- Iteration 25 --
                    169: float(0)
                    170: 
                    171: -- Iteration 26 --
                    172: float(%f)
                    173: ===Done===

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