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