Annotation of embedaddon/php/ext/standard/tests/array/array_sum_variation1.phpt, revision 1.1.1.1

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

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