Revert "make hphpc able to use ini files"
[hiphop-php.git] / hphp / test / zend / bad / ext / standard / tests / array / uasort_error.php
blob005504dcce51243c767b54a448c782eed8f00e00
1 <?php
2 /* Prototype : bool uasort(array $array_arg, string $cmp_function)
3 * Description: Sort an array with a user-defined comparison function and maintain index association
4 * Source code: ext/standard/array.c
5 */
7 echo "*** Testing uasort() : error conditions ***\n";
9 // comparison function
10 /* Prototype : int cmp(mixed $value1, mixed $value2)
11 * Parameters : $value1 and $value2 - values to be compared
12 * Return value : 0 - if both values are same
13 * 1 - if value1 is greater than value2
14 * -1 - if value1 is less than value2
15 * Description : compares value1 and value2
17 function cmp($value1, $value2)
19 if($value1 == $value2) {
20 return 0;
22 else if($value1 > $value2) {
23 return 1;
25 else {
26 return -1;
30 // Initialize 'array_arg'
31 $array_arg = array(0 => 1, 1 => 10, 2 => 'string', 3 => 3, 4 => 2, 5 => 100, 6 => 25);
33 // With zero arguments
34 echo "-- Testing uasort() function with Zero argument --\n";
35 var_dump( uasort() );
37 // With one more than the expected number of arguments
38 echo "-- Testing uasort() function with more than expected no. of arguments --\n";
39 $extra_arg = 10;
40 var_dump( uasort($array_arg, 'cmp', $extra_arg) );
42 // With one less than the expected number of arguments
43 echo "-- Testing uasort() function with less than expected no. of arguments --\n";
44 var_dump( uasort($array_arg) );
46 // With non existent comparison function
47 echo "-- Testing uasort() function with non-existent compare function --\n";
48 var_dump( uasort($array_arg, 'non_existent') );
50 // With non existent comparison function and extra argument
51 echo "-- Testing uasort() function with non-existent compare function and extra argument --\n";
52 var_dump( uasort($array_arg, 'non_existent', $extra_arg) );
54 echo "Done"