Annotation of embedaddon/php/ext/standard/tests/array/sort_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test sort() function : usage variations - unexpected values for 'array_arg' argument
3: --FILE--
4: <?php
5: /* Prototype : bool sort(array &array_arg [, int $sort_flags])
6: * Description: Sort an array
7: * Source code: ext/standard/array.c
8: */
9:
10: /*
11: * testing sort() by providing different unexpected values for array argument
12: * with following flag values.
13: * 1. flag value as defualt
14: * 2. SORT_REGULAR - compare items normally
15: * 3. SORT_NUMERIC - compare items numerically
16: * 4. SORT_STRING - compare items as strings
17: */
18:
19: echo "*** Testing sort() : usage variations ***\n";
20:
21: //get an unset variable
22: $unset_var = 10;
23: unset ($unset_var);
24:
25: // resource variable
26: $fp = fopen(__FILE__, "r");
27:
28: //array of values to iterate over
29: $unexpected_values = array (
30:
31: // int data
32: /*1*/ 0,
33: 1,
34: 12345,
35: -2345,
36:
37: // float data
38: /*5*/ 10.5,
39: -10.5,
40: 10.5e3,
41: 10.6E-2,
42: .5,
43:
44: // null data
45: /*10*/ NULL,
46: null,
47:
48: // boolean data
49: /*12*/ true,
50: false,
51: TRUE,
52: FALSE,
53:
54: // empty data
55: /*16*/ "",
56: '',
57:
58: // string data
59: /*18*/ "string",
60: 'string',
61:
62: // object data
63: /*20*/ new stdclass(),
64:
65: // undefined data
66: /*21*/ @undefined_var,
67:
68: // unset data
69: /*22*/ @unset_var,
70:
71: // resource variable
72: /*23*/ $fp
73: );
74:
75: // loop though each element of the array and check the working of sort()
76: // when $array arugment is supplied with different values from $unexpected_values
77: echo "\n-- Testing sort() by supplying different unexpected values for 'array' argument --\n";
78: echo "\n-- Flag values are defualt, SORT_REGULAR, SORT_NUMERIC, SORT_STRING --\n";
79:
80: $counter = 1;
81: for($index = 0; $index < count($unexpected_values); $index ++) {
82: echo "-- Iteration $counter --\n";
83: $value = $unexpected_values [$index];
84: var_dump( sort($value) ); // expecting : bool(false)
85: var_dump( sort($value, SORT_REGULAR) ); // expecting : bool(false)
86: var_dump( sort($value, SORT_NUMERIC) ); // expecting : bool(false)
87: var_dump( sort($value, SORT_STRING) ); // expecting : bool(false)
88: $counter++;
89: }
90:
91: echo "Done";
92: ?>
93: --EXPECTF--
94: *** Testing sort() : usage variations ***
95:
96: -- Testing sort() by supplying different unexpected values for 'array' argument --
97:
98: -- Flag values are defualt, SORT_REGULAR, SORT_NUMERIC, SORT_STRING --
99: -- Iteration 1 --
100:
101: Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
102: bool(false)
103:
104: Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
105: bool(false)
106:
107: Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
108: bool(false)
109:
110: Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
111: bool(false)
112: -- Iteration 2 --
113:
114: Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
115: bool(false)
116:
117: Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
118: bool(false)
119:
120: Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
121: bool(false)
122:
123: Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
124: bool(false)
125: -- Iteration 3 --
126:
127: Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
128: bool(false)
129:
130: Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
131: bool(false)
132:
133: Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
134: bool(false)
135:
136: Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
137: bool(false)
138: -- Iteration 4 --
139:
140: Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
141: bool(false)
142:
143: Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
144: bool(false)
145:
146: Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
147: bool(false)
148:
149: Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
150: bool(false)
151: -- Iteration 5 --
152:
153: Warning: sort() expects parameter 1 to be array, double given in %s on line %d
154: bool(false)
155:
156: Warning: sort() expects parameter 1 to be array, double given in %s on line %d
157: bool(false)
158:
159: Warning: sort() expects parameter 1 to be array, double given in %s on line %d
160: bool(false)
161:
162: Warning: sort() expects parameter 1 to be array, double given in %s on line %d
163: bool(false)
164: -- Iteration 6 --
165:
166: Warning: sort() expects parameter 1 to be array, double given in %s on line %d
167: bool(false)
168:
169: Warning: sort() expects parameter 1 to be array, double given in %s on line %d
170: bool(false)
171:
172: Warning: sort() expects parameter 1 to be array, double given in %s on line %d
173: bool(false)
174:
175: Warning: sort() expects parameter 1 to be array, double given in %s on line %d
176: bool(false)
177: -- Iteration 7 --
178:
179: Warning: sort() expects parameter 1 to be array, double given in %s on line %d
180: bool(false)
181:
182: Warning: sort() expects parameter 1 to be array, double given in %s on line %d
183: bool(false)
184:
185: Warning: sort() expects parameter 1 to be array, double given in %s on line %d
186: bool(false)
187:
188: Warning: sort() expects parameter 1 to be array, double given in %s on line %d
189: bool(false)
190: -- Iteration 8 --
191:
192: Warning: sort() expects parameter 1 to be array, double given in %s on line %d
193: bool(false)
194:
195: Warning: sort() expects parameter 1 to be array, double given in %s on line %d
196: bool(false)
197:
198: Warning: sort() expects parameter 1 to be array, double given in %s on line %d
199: bool(false)
200:
201: Warning: sort() expects parameter 1 to be array, double given in %s on line %d
202: bool(false)
203: -- Iteration 9 --
204:
205: Warning: sort() expects parameter 1 to be array, double given in %s on line %d
206: bool(false)
207:
208: Warning: sort() expects parameter 1 to be array, double given in %s on line %d
209: bool(false)
210:
211: Warning: sort() expects parameter 1 to be array, double given in %s on line %d
212: bool(false)
213:
214: Warning: sort() expects parameter 1 to be array, double given in %s on line %d
215: bool(false)
216: -- Iteration 10 --
217:
218: Warning: sort() expects parameter 1 to be array, null given in %s on line %d
219: bool(false)
220:
221: Warning: sort() expects parameter 1 to be array, null given in %s on line %d
222: bool(false)
223:
224: Warning: sort() expects parameter 1 to be array, null given in %s on line %d
225: bool(false)
226:
227: Warning: sort() expects parameter 1 to be array, null given in %s on line %d
228: bool(false)
229: -- Iteration 11 --
230:
231: Warning: sort() expects parameter 1 to be array, null given in %s on line %d
232: bool(false)
233:
234: Warning: sort() expects parameter 1 to be array, null given in %s on line %d
235: bool(false)
236:
237: Warning: sort() expects parameter 1 to be array, null given in %s on line %d
238: bool(false)
239:
240: Warning: sort() expects parameter 1 to be array, null given in %s on line %d
241: bool(false)
242: -- Iteration 12 --
243:
244: Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
245: bool(false)
246:
247: Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
248: bool(false)
249:
250: Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
251: bool(false)
252:
253: Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
254: bool(false)
255: -- Iteration 13 --
256:
257: Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
258: bool(false)
259:
260: Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
261: bool(false)
262:
263: Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
264: bool(false)
265:
266: Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
267: bool(false)
268: -- Iteration 14 --
269:
270: Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
271: bool(false)
272:
273: Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
274: bool(false)
275:
276: Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
277: bool(false)
278:
279: Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
280: bool(false)
281: -- Iteration 15 --
282:
283: Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
284: bool(false)
285:
286: Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
287: bool(false)
288:
289: Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
290: bool(false)
291:
292: Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
293: bool(false)
294: -- Iteration 16 --
295:
296: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
297: bool(false)
298:
299: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
300: bool(false)
301:
302: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
303: bool(false)
304:
305: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
306: bool(false)
307: -- Iteration 17 --
308:
309: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
310: bool(false)
311:
312: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
313: bool(false)
314:
315: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
316: bool(false)
317:
318: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
319: bool(false)
320: -- Iteration 18 --
321:
322: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
323: bool(false)
324:
325: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
326: bool(false)
327:
328: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
329: bool(false)
330:
331: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
332: bool(false)
333: -- Iteration 19 --
334:
335: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
336: bool(false)
337:
338: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
339: bool(false)
340:
341: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
342: bool(false)
343:
344: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
345: bool(false)
346: -- Iteration 20 --
347:
348: Warning: sort() expects parameter 1 to be array, object given in %s on line %d
349: bool(false)
350:
351: Warning: sort() expects parameter 1 to be array, object given in %s on line %d
352: bool(false)
353:
354: Warning: sort() expects parameter 1 to be array, object given in %s on line %d
355: bool(false)
356:
357: Warning: sort() expects parameter 1 to be array, object given in %s on line %d
358: bool(false)
359: -- Iteration 21 --
360:
361: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
362: bool(false)
363:
364: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
365: bool(false)
366:
367: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
368: bool(false)
369:
370: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
371: bool(false)
372: -- Iteration 22 --
373:
374: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
375: bool(false)
376:
377: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
378: bool(false)
379:
380: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
381: bool(false)
382:
383: Warning: sort() expects parameter 1 to be array, string given in %s on line %d
384: bool(false)
385: -- Iteration 23 --
386:
387: Warning: sort() expects parameter 1 to be array, resource given in %s on line %d
388: bool(false)
389:
390: Warning: sort() expects parameter 1 to be array, resource given in %s on line %d
391: bool(false)
392:
393: Warning: sort() expects parameter 1 to be array, resource given in %s on line %d
394: bool(false)
395:
396: Warning: sort() expects parameter 1 to be array, resource given in %s on line %d
397: bool(false)
398: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>