import zend standard tests
[hiphop-php.git] / hphp / test / zend / good / ext-standard-array / array_unique_variation1.php
blob7d74e351bb6e1fd9d9b02a8f964332c431f75b2e
1 <?php
2 /* Prototype : array array_unique(array $input)
3 * Description: Removes duplicate values from array
4 * Source code: ext/standard/array.c
5 */
7 /*
8 * Passing non array values to 'input' argument of array_unique() and see
9 * that the function outputs proper warning messages wherever expected.
12 echo "*** Testing array_unique() : Passing non array values to \$input argument ***\n";
14 //get an unset variable
15 $unset_var = 10;
16 unset($unset_var);
18 // get a class
19 class classA
21 public function __toString() {
22 return "Class A object";
26 // heredoc string
27 $heredoc = <<<EOT
28 hello world
29 EOT;
31 // get a resource variable
32 $fp = fopen(__FILE__, "r");
34 // unexpected values to be passed to $input argument
35 $inputs = array (
37 // int data
38 /*1*/ 0,
40 12345,
41 -2345,
43 // float data
44 /*5*/ 10.5,
45 -10.5,
46 12.3456789000e10,
47 12.3456789000E-10,
48 .5,
50 // null data
51 /*10*/ NULL,
52 null,
54 // boolean data
55 /*12*/ true,
56 false,
57 TRUE,
58 FALSE,
60 // empty data
61 /*16*/ "",
62 '',
64 // string data
65 /*18*/ "string",
66 'string',
67 $heredoc,
69 // object data
70 /*21*/ new classA(),
72 // undefined data
73 /*22*/ @$undefined_var,
75 // unset data
76 /*23*/ @$unset_var,
78 // resource variable
79 /*24*/ $fp
82 // loop through each element of $inputs and check the behavior of array_unique()
83 $iterator = 1;
84 foreach($inputs as $input) {
85 echo "-- Iteration $iterator --\n";
86 var_dump( array_unique($input) );
87 $iterator++;
90 fclose($fp);
92 echo "Done";