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