TypePHP 编译器
https://swoole.com/aot/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
956 B
37 lines
956 B
--TEST--
|
|
Test array_reduce() function : variation
|
|
--SKIPIF--
|
|
<?php die("skip AOT does not support string-based callbacks"); ?>
|
|
|
|
--FILE--
|
|
<?php
|
|
function oneArg($v)
|
|
{
|
|
return $v;
|
|
}
|
|
function threeArgs($v, $w, $x)
|
|
{
|
|
return $v + $w + $x;
|
|
}
|
|
function main()
|
|
{
|
|
echo "*** Testing array_reduce() : variation ***\n";
|
|
$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";
|
|
try {
|
|
var_dump(array_reduce($array, "threeArgs", 2));
|
|
} catch (Throwable $e) {
|
|
echo "Exception: " . $e->getMessage() . "\n";
|
|
}
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
*** Testing array_reduce() : variation ***
|
|
|
|
--- Testing with a callback with too few parameters ---
|
|
int(2)
|
|
|
|
--- Testing with a callback with too many parameters ---
|
|
Exception: Too few arguments to function threeArgs(), 2 passed and exactly 3 expected
|
|
|