Annotation of embedaddon/php/ext/standard/tests/array/array_diff_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test array_diff() function : usage variations - unexpected values for 'arr1' argument
3: --FILE--
4: <?php
5: /* Prototype : array array_diff(array $arr1, array $arr2 [, array ...])
6: * Description: Returns the entries of $arr1 that have values which are not
7: * present in any of the others arguments.
8: * Source code: ext/standard/array.c
9: */
10:
11: /*
12: * Test array_diff by passing non array values in place of $arr1
13: */
14:
15: echo "*** Testing array_diff() : usage variations ***\n";
16:
17: $array = array(1, 2, 3);
18:
19: //get an unset variable
20: $unset_var = 10;
21: unset ($unset_var);
22:
23: // get a class
24: class classA
25: {
26: public function __toString() {
27: return "Class A object";
28: }
29: }
30:
31: // heredoc string
32: $heredoc = <<<EOT
33: hello world
34: EOT;
35:
36: // get a resource variable
37: $fp = fopen(__FILE__, "r");
38:
39: // unexpected values to be passed to $input argument
40: $inputs = array(
41:
42: // int data
43: /*1*/ 0,
44: 1,
45: 12345,
46: -2345,
47:
48: // float data
49: /*5*/ 10.5,
50: -10.5,
51: 12.3456789000e10,
52: 12.3456789000E-10,
53: .5,
54:
55: // null data
56: /*10*/ NULL,
57: null,
58:
59: // boolean data
60: /*12*/ true,
61: false,
62: TRUE,
63: FALSE,
64:
65: // empty data
66: /*16*/ "",
67: '',
68:
69: // string data
70: /*18*/ "string",
71: 'string',
72: $heredoc,
73:
74: // binary data
75: /*21*/ b"binary",
76: (binary)"binary",
77:
78: // object data
79: /*23*/ new classA(),
80:
81: // undefined data
82: /*24*/ @$undefined_var,
83:
84: // unset data
85: /*25*/ @$unset_var,
86:
87: // resource variable
88: /*26*/ $fp
89: );
90:
91: // loop through each element of $inputs to check the behavior of array_diff
92: $iterator = 1;
93: foreach($inputs as $input) {
94: echo "\n-- Iteration $iterator --";
95: var_dump( array_diff($input, $array));
96: $iterator++;
97: };
98:
99: fclose($fp);
100: echo "Done";
101: ?>
102: --EXPECTF--
103: *** Testing array_diff() : usage variations ***
104:
105: -- Iteration 1 --
106: Warning: array_diff(): Argument #1 is not an array in %s on line %d
107: NULL
108:
109: -- Iteration 2 --
110: Warning: array_diff(): Argument #1 is not an array in %s on line %d
111: NULL
112:
113: -- Iteration 3 --
114: Warning: array_diff(): Argument #1 is not an array in %s on line %d
115: NULL
116:
117: -- Iteration 4 --
118: Warning: array_diff(): Argument #1 is not an array in %s on line %d
119: NULL
120:
121: -- Iteration 5 --
122: Warning: array_diff(): Argument #1 is not an array in %s on line %d
123: NULL
124:
125: -- Iteration 6 --
126: Warning: array_diff(): Argument #1 is not an array in %s on line %d
127: NULL
128:
129: -- Iteration 7 --
130: Warning: array_diff(): Argument #1 is not an array in %s on line %d
131: NULL
132:
133: -- Iteration 8 --
134: Warning: array_diff(): Argument #1 is not an array in %s on line %d
135: NULL
136:
137: -- Iteration 9 --
138: Warning: array_diff(): Argument #1 is not an array in %s on line %d
139: NULL
140:
141: -- Iteration 10 --
142: Warning: array_diff(): Argument #1 is not an array in %s on line %d
143: NULL
144:
145: -- Iteration 11 --
146: Warning: array_diff(): Argument #1 is not an array in %s on line %d
147: NULL
148:
149: -- Iteration 12 --
150: Warning: array_diff(): Argument #1 is not an array in %s on line %d
151: NULL
152:
153: -- Iteration 13 --
154: Warning: array_diff(): Argument #1 is not an array in %s on line %d
155: NULL
156:
157: -- Iteration 14 --
158: Warning: array_diff(): Argument #1 is not an array in %s on line %d
159: NULL
160:
161: -- Iteration 15 --
162: Warning: array_diff(): Argument #1 is not an array in %s on line %d
163: NULL
164:
165: -- Iteration 16 --
166: Warning: array_diff(): Argument #1 is not an array in %s on line %d
167: NULL
168:
169: -- Iteration 17 --
170: Warning: array_diff(): Argument #1 is not an array in %s on line %d
171: NULL
172:
173: -- Iteration 18 --
174: Warning: array_diff(): Argument #1 is not an array in %s on line %d
175: NULL
176:
177: -- Iteration 19 --
178: Warning: array_diff(): Argument #1 is not an array in %s on line %d
179: NULL
180:
181: -- Iteration 20 --
182: Warning: array_diff(): Argument #1 is not an array in %s on line %d
183: NULL
184:
185: -- Iteration 21 --
186: Warning: array_diff(): Argument #1 is not an array in %s on line %d
187: NULL
188:
189: -- Iteration 22 --
190: Warning: array_diff(): Argument #1 is not an array in %s on line %d
191: NULL
192:
193: -- Iteration 23 --
194: Warning: array_diff(): Argument #1 is not an array in %s on line %d
195: NULL
196:
197: -- Iteration 24 --
198: Warning: array_diff(): Argument #1 is not an array in %s on line %d
199: NULL
200:
201: -- Iteration 25 --
202: Warning: array_diff(): Argument #1 is not an array in %s on line %d
203: NULL
204:
205: -- Iteration 26 --
206: Warning: array_diff(): Argument #1 is not an array in %s on line %d
207: NULL
208: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>