Annotation of embedaddon/php/ext/standard/tests/array/count_error.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test count() function : error conditions - pass incorrect number of args
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : int count(mixed var [, int mode])
! 6: * Description: Count the number of elements in a variable (usually an array)
! 7: * Source code: ext/standard/array.c
! 8: */
! 9:
! 10: /*
! 11: * Pass incorrect number of arguments to count() to test behaviour
! 12: */
! 13:
! 14: echo "*** Testing count() : error conditions ***\n";
! 15:
! 16: // Zero arguments
! 17: echo "\n-- Testing count() function with Zero arguments --\n";
! 18: var_dump( count() );
! 19:
! 20: //Test count with one more than the expected number of arguments
! 21: echo "\n-- Testing count() function with more than expected no. of arguments --\n";
! 22: $var = 1;
! 23: $mode = 10;
! 24: $extra_arg = 10;
! 25: var_dump( count($var, $mode, $extra_arg) );
! 26:
! 27: echo "Done";
! 28: ?>
! 29: --EXPECTF--
! 30: *** Testing count() : error conditions ***
! 31:
! 32: -- Testing count() function with Zero arguments --
! 33:
! 34: Warning: count() expects at least 1 parameter, 0 given in %s on line %d
! 35: NULL
! 36:
! 37: -- Testing count() function with more than expected no. of arguments --
! 38:
! 39: Warning: count() expects at most 2 parameters, 3 given in %s on line %d
! 40: NULL
! 41: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>