1--TEST--
2Test array_udiff() function : usage variation
3--FILE--
4<?php
5echo "*** Testing array_udiff() : usage variation ***\n";
6
7// Initialise function arguments not being substituted (if any)
8$arr1 = array(1);
9$arr2 = array(1);
10
11echo "\n-- comparison function with an incorrect return value --\n";
12function incorrect_return_value ($val1, $val2) {
13  return array(1);
14}
15var_dump(array_udiff($arr1, $arr2, 'incorrect_return_value'));
16
17echo "\n-- comparison function taking too many parameters --\n";
18function too_many_parameters ($val1, $val2, $val3) {
19  return 0;
20}
21try {
22    var_dump(array_udiff($arr1, $arr2, 'too_many_parameters'));
23} catch (Throwable $e) {
24    echo "Exception: " . $e->getMessage() . "\n";
25}
26
27echo "\n-- comparison function taking too few parameters --\n";
28function too_few_parameters ($val1) {
29  return 0;
30}
31var_dump(array_udiff($arr1, $arr2, 'too_few_parameters'));
32
33?>
34--EXPECT--
35*** Testing array_udiff() : usage variation ***
36
37-- comparison function with an incorrect return value --
38array(1) {
39  [0]=>
40  int(1)
41}
42
43-- comparison function taking too many parameters --
44Exception: Too few arguments to function too_many_parameters(), 2 passed and exactly 3 expected
45
46-- comparison function taking too few parameters --
47array(0) {
48}
49