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

1.1       misho       1: --TEST--
                      2: Test array_map() function : error conditions
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : array array_map  ( callback $callback  , array $arr1  [, array $...  ] )
                      6:  * Description: Applies the callback to the elements of the given arrays
                      7:  * Source code: ext/standard/array.c
                      8:  */
                      9: 
                     10: echo "*** Testing array_map() : error conditions ***\n";
                     11: 
                     12: // Zero arguments
                     13: echo "\n-- Testing array_map() function with Zero arguments --\n";
                     14: var_dump( array_map() );
                     15: 
                     16: // Testing array_map with one less than the expected number of arguments
                     17: echo "\n-- Testing array_map() function with one less than expected no. of arguments --\n";
                     18: function callback1() {
                     19:   return 1;
                     20: }
                     21: var_dump( array_map('callback1') );
                     22: 
                     23: echo "\n-- Testing array_map() function with less no. of arrays than callback function arguments --\n";
                     24: $arr1 = array(1, 2);
                     25: function callback2($p, $q) {
                     26:   return $p * $q;
                     27: }
                     28: var_dump( array_map('callback2', $arr1) );
                     29: 
                     30: echo "\n-- Testing array_map() function with more no. of arrays than callback function arguments --\n";
                     31: $arr2 = array(3, 4);
                     32: $arr3 = array(5, 6);
                     33: var_dump( array_map('callback2', $arr1, $arr2, $arr3) );
                     34: 
                     35: echo "Done";
                     36: ?>
                     37: --EXPECTF--
                     38: *** Testing array_map() : error conditions ***
                     39: 
                     40: -- Testing array_map() function with Zero arguments --
                     41: 
                     42: Warning: array_map() expects at least 2 parameters, 0 given in %s on line %d%d
                     43: NULL
                     44: 
                     45: -- Testing array_map() function with one less than expected no. of arguments --
                     46: 
                     47: Warning: array_map() expects at least 2 parameters, 1 given in %s on line %d%d
                     48: NULL
                     49: 
                     50: -- Testing array_map() function with less no. of arrays than callback function arguments --
                     51: 
                     52: Warning: Missing argument 2 for callback2() in %s on line %d%d
                     53: 
                     54: Notice: Undefined variable: q in %s on line %d%d
                     55: 
                     56: Warning: Missing argument 2 for callback2() in %s on line %d%d
                     57: 
                     58: Notice: Undefined variable: q in %s on line %d%d
                     59: array(2) {
                     60:   [0]=>
                     61:   int(0)
                     62:   [1]=>
                     63:   int(0)
                     64: }
                     65: 
                     66: -- Testing array_map() function with more no. of arrays than callback function arguments --
                     67: array(2) {
                     68:   [0]=>
                     69:   int(3)
                     70:   [1]=>
                     71:   int(8)
                     72: }
                     73: Done

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