diff options
Diffstat (limited to 'ext/standard/tests/array/array_reduce_variation1.phpt')
-rw-r--r-- | ext/standard/tests/array/array_reduce_variation1.phpt | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/ext/standard/tests/array/array_reduce_variation1.phpt b/ext/standard/tests/array/array_reduce_variation1.phpt new file mode 100644 index 0000000..b02a82a --- /dev/null +++ b/ext/standard/tests/array/array_reduce_variation1.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test array_reduce() function : variation +--FILE-- +<?php +/* Prototype : mixed array_reduce(array input, mixed callback [, int initial]) + * Description: Iteratively reduce the array to a single value via the callback. + * Source code: ext/standard/array.c + * Alias to functions: + */ + +echo "*** Testing array_reduce() : variation ***\n"; + + +function oneArg($v) { + return $v; +} + +function threeArgs($v, $w, $x) { + return $v + $w + $x; +} + +$array = array(1); + +echo "\n--- Testing with a callback with too few parameters ---\n"; +var_dump(array_reduce($array, "oneArg", 2)); + +echo "\n--- Testing with a callback with too many parameters ---\n"; +var_dump(array_reduce($array, "threeArgs", 2)); + +?> +===DONE=== +--EXPECTF-- +*** Testing array_reduce() : variation *** + +--- Testing with a callback with too few parameters --- +int(2) + +--- Testing with a callback with too many parameters --- + +Warning: Missing argument 3 for threeArgs() in %sarray_reduce_variation1.php on line %d + +Notice: Undefined variable: x in %sarray_reduce_variation1.php on line %d +int(3) +===DONE===
\ No newline at end of file |