Annotation of embedaddon/php/ext/standard/tests/array/uksort_variation2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test uksort() function : usage variation
3: --FILE--
4: <?php
5: /* Prototype : bool uksort(array array_arg, string cmp_function)
6: * Description: Sort an array by keys using a user-defined comparison function
7: * Source code: ext/standard/array.c
8: * Alias to functions:
9: */
10:
11: echo "*** Testing uksort() : usage variation ***\n";
12:
13: // Initialise function arguments not being substituted (if any)
14: $array_arg = array(1, 2);
15:
16: //get an unset variable
17: $unset_var = 10;
18: unset ($unset_var);
19:
20: // define some classes
21: class classWithToString
22: {
23: public function __toString() {
24: return "Class A object";
25: }
26: }
27:
28: class classWithoutToString
29: {
30: }
31:
32: // heredoc string
33: $heredoc = <<<EOT
34: hello world
35: EOT;
36:
37: // add arrays
38: $index_array = array (1, 2, 3);
39: $assoc_array = array ('one' => 1, 'two' => 2);
40:
41: //array of values to iterate over
42: $inputs = array(
43:
44: // int data
45: 'int 0' => 0,
46: 'int 1' => 1,
47: 'int 12345' => 12345,
48: 'int -12345' => -2345,
49:
50: // float data
51: 'float 10.5' => 10.5,
52: 'float -10.5' => -10.5,
53: 'float 12.3456789000e10' => 12.3456789000e10,
54: 'float -12.3456789000e10' => -12.3456789000e10,
55: 'float .5' => .5,
56:
57: // array data
58: 'empty array' => array(),
59: 'int indexed array' => $index_array,
60: 'associative array' => $assoc_array,
61: 'nested arrays' => array('foo', $index_array, $assoc_array),
62:
63: // null data
64: 'uppercase NULL' => NULL,
65: 'lowercase null' => null,
66:
67: // boolean data
68: 'lowercase true' => true,
69: 'lowercase false' =>false,
70: 'uppercase TRUE' =>TRUE,
71: 'uppercase FALSE' =>FALSE,
72:
73: // empty data
74: 'empty string DQ' => "",
75: 'empty string SQ' => '',
76:
77: // object data
78: 'instance of classWithToString' => new classWithToString(),
79: 'instance of classWithoutToString' => new classWithoutToString(),
80:
81: // undefined data
82: 'undefined var' => @$undefined_var,
83:
84: // unset data
85: 'unset var' => @$unset_var,
86: );
87:
88: // loop through each element of the array for cmp_function
89:
90: foreach($inputs as $key =>$value) {
91: echo "\n--$key--\n";
92: var_dump( uksort($array_arg, $value) );
93: };
94:
95: ?>
96: ===DONE===
97: --EXPECTF--
98: *** Testing uksort() : usage variation ***
99:
100: --int 0--
101:
102: Warning: uksort() expects parameter 2 to be a valid callback, no array or string given in %suksort_variation2.php on line %d
103: NULL
104:
105: --int 1--
106:
107: Warning: uksort() expects parameter 2 to be a valid callback, no array or string given in %suksort_variation2.php on line %d
108: NULL
109:
110: --int 12345--
111:
112: Warning: uksort() expects parameter 2 to be a valid callback, no array or string given in %suksort_variation2.php on line %d
113: NULL
114:
115: --int -12345--
116:
117: Warning: uksort() expects parameter 2 to be a valid callback, no array or string given in %suksort_variation2.php on line %d
118: NULL
119:
120: --float 10.5--
121:
122: Warning: uksort() expects parameter 2 to be a valid callback, no array or string given in %suksort_variation2.php on line %d
123: NULL
124:
125: --float -10.5--
126:
127: Warning: uksort() expects parameter 2 to be a valid callback, no array or string given in %suksort_variation2.php on line %d
128: NULL
129:
130: --float 12.3456789000e10--
131:
132: Warning: uksort() expects parameter 2 to be a valid callback, no array or string given in %suksort_variation2.php on line %d
133: NULL
134:
135: --float -12.3456789000e10--
136:
137: Warning: uksort() expects parameter 2 to be a valid callback, no array or string given in %suksort_variation2.php on line %d
138: NULL
139:
140: --float .5--
141:
142: Warning: uksort() expects parameter 2 to be a valid callback, no array or string given in %suksort_variation2.php on line %d
143: NULL
144:
145: --empty array--
146:
147: Warning: uksort() expects parameter 2 to be a valid callback, array must have exactly two members in %suksort_variation2.php on line %d
148: NULL
149:
150: --int indexed array--
151:
152: Warning: uksort() expects parameter 2 to be a valid callback, array must have exactly two members in %suksort_variation2.php on line %d
153: NULL
154:
155: --associative array--
156:
157: Warning: uksort() expects parameter 2 to be a valid callback, first array member is not a valid class name or object in %suksort_variation2.php on line %d
158: NULL
159:
160: --nested arrays--
161:
162: Warning: uksort() expects parameter 2 to be a valid callback, array must have exactly two members in %suksort_variation2.php on line %d
163: NULL
164:
165: --uppercase NULL--
166:
167: Warning: uksort() expects parameter 2 to be a valid callback, no array or string given in %suksort_variation2.php on line %d
168: NULL
169:
170: --lowercase null--
171:
172: Warning: uksort() expects parameter 2 to be a valid callback, no array or string given in %suksort_variation2.php on line %d
173: NULL
174:
175: --lowercase true--
176:
177: Warning: uksort() expects parameter 2 to be a valid callback, no array or string given in %suksort_variation2.php on line %d
178: NULL
179:
180: --lowercase false--
181:
182: Warning: uksort() expects parameter 2 to be a valid callback, no array or string given in %suksort_variation2.php on line %d
183: NULL
184:
185: --uppercase TRUE--
186:
187: Warning: uksort() expects parameter 2 to be a valid callback, no array or string given in %suksort_variation2.php on line %d
188: NULL
189:
190: --uppercase FALSE--
191:
192: Warning: uksort() expects parameter 2 to be a valid callback, no array or string given in %suksort_variation2.php on line %d
193: NULL
194:
195: --empty string DQ--
196:
197: Warning: uksort() expects parameter 2 to be a valid callback, function '' not found or invalid function name in %suksort_variation2.php on line %d
198: NULL
199:
200: --empty string SQ--
201:
202: Warning: uksort() expects parameter 2 to be a valid callback, function '' not found or invalid function name in %suksort_variation2.php on line %d
203: NULL
204:
205: --instance of classWithToString--
206:
207: Warning: uksort() expects parameter 2 to be a valid callback, no array or string given in %suksort_variation2.php on line %d
208: NULL
209:
210: --instance of classWithoutToString--
211:
212: Warning: uksort() expects parameter 2 to be a valid callback, no array or string given in %suksort_variation2.php on line %d
213: NULL
214:
215: --undefined var--
216:
217: Warning: uksort() expects parameter 2 to be a valid callback, no array or string given in %suksort_variation2.php on line %d
218: NULL
219:
220: --unset var--
221:
222: Warning: uksort() expects parameter 2 to be a valid callback, no array or string given in %suksort_variation2.php on line %d
223: NULL
224: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>