import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-array / asort_variation2.php
blobe1bddab3865819762cb41a36f9018d0a8fdaf9d2
1 <?php
2 /* Prototype : proto bool asort(array &array_arg [, int sort_flags])
3 * Description: Sort an array and maintain index association
4 Elements will be arranged from lowest to highest when this function has completed.
5 * Source code: ext/standard/array.c
6 */
8 /*
9 * Testing asort() by providing different unexpected values for flag argument
12 echo "*** Testing asort() : usage variations ***\n";
14 //get an unset variable
15 $unset_var = 10;
16 unset ($unset_var);
18 // resource variable
19 $fp = fopen(__FILE__, "r");
21 // temperory array for checking unexpected behavior
22 $unsorted_values = array(1 => 10, 2 => 2, 3 => 45);
24 //array of values to iterate over
25 $unexpected_values = array(
27 // int data
28 /*1*/ -2345,
30 // float data
31 /*2*/ 10.5,
32 -10.5,
33 10.5e2,
34 10.6E-2,
35 .5,
37 // null data
38 /*7*/ NULL,
39 null,
41 // boolean data
42 /*9*/ true,
43 false,
44 TRUE,
45 FALSE,
47 // empty data
48 /*13*/ "",
49 '',
51 // string data
52 /*15*/ "string",
53 'string',
55 // object data
56 /*16*/ new stdclass(),
58 // undefined data
59 /*17*/ @undefined_var,
61 // unset data
62 /*18*/ @unset_var,
64 // resource variable
65 /*19*/ $fp
69 // loop though each element of the array and check the working of asort()
70 // when $flag arugment is supplied with different values from $unexpected_values
71 echo "\n-- Testing asort() by supplying different unexpected values for 'sort_flags' argument --\n";
73 $counter = 1;
74 for($index = 0; $index < count($unexpected_values); $index ++) {
75 echo "-- Iteration $counter --\n";
76 $value = $unexpected_values [$index];
77 $temp_array = $unsorted_values;
78 var_dump( asort($temp_array, $value) );
79 var_dump($temp_array);
80 $counter++;
83 echo "Done";