import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-array / rsort_variation2.php
blob36e4494e53818310e8f88c18499673a87d389a7a
1 <?php
2 /* Prototype : bool rsort(array &$array_arg [, int $sort_flags])
3 * Description: Sort an array in reverse order
4 * Source code: ext/standard/array.c
5 */
7 /*
8 * Pass different data types as $sort_flags argument to rsort() to test behaviour
9 * Where possible, 'SORT_NUMERIC' has been entered as a string value
12 echo "*** Testing rsort() : variation ***\n";
14 // Initialise function arguments not being substituted
15 $array_arg = array (1, 5, 2, 3, 1);
17 //get an unset variable
18 $unset_var = 10;
19 unset ($unset_var);
21 // get a class
22 class classA
24 public function __toString() {
25 return "SORT_NUMERIC";
29 // heredoc string
30 $heredoc = <<<EOT
31 SORT_NUMERIC
32 EOT;
34 // get a resource variable
35 $fp = fopen(__FILE__, "r");
37 // unexpected values to be passed to $sort_flags argument
38 $inputs = array(
40 // int data
41 /*1*/ 0,
43 12345,
44 -2345,
46 // float data
47 /*5*/ 10.5,
48 -10.5,
49 12.3456789000e10,
50 12.3456789000E-10,
51 .5,
53 // null data
54 /*10*/ NULL,
55 null,
57 // boolean data
58 /*12*/ true,
59 false,
60 TRUE,
61 FALSE,
63 // empty data
64 /*16*/ "",
65 '',
67 // string data
68 /*18*/ "SORT_NUMERIC",
69 'SORT_NUMERIC',
70 $heredoc,
72 // object data
73 /*21*/ new classA(),
75 // undefined data
76 /*22*/ @$undefined_var,
78 // unset data
79 /*23*/ @$unset_var,
81 // resource variable
82 /*24*/ $fp
85 // loop through each element of $inputs to check the behavior of rsort()
86 $iterator = 1;
87 foreach($inputs as $input) {
88 echo "\n-- Iteration $iterator --\n";
90 //create temporary array in case rsort() works
91 $temp = $array_arg;
93 var_dump( rsort($temp, $input) );
94 var_dump($temp);
95 $iterator++;
97 $temp = null;
100 fclose($fp);
102 echo "Done";