1--TEST--
2Test >> operator : various numbers as strings
3--FILE--
4<?php
5
6$strVals = array(
7   "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a",
8   "a5.9"
9);
10
11error_reporting(E_ERROR);
12
13foreach ($strVals as $strVal) {
14   foreach($strVals as $otherVal) {
15	  echo "--- testing: '$strVal' >> '$otherVal' ---\n";
16	  try {
17        var_dump($strVal>>$otherVal);
18      } catch (ArithmeticError $e) {
19        echo "Exception: " . $e->getMessage() . "\n";
20      }
21   }
22}
23
24
25?>
26===DONE===
27--EXPECT--
28--- testing: '0' >> '0' ---
29int(0)
30--- testing: '0' >> '65' ---
31int(0)
32--- testing: '0' >> '-44' ---
33Exception: Bit shift by negative number
34--- testing: '0' >> '1.2' ---
35int(0)
36--- testing: '0' >> '-7.7' ---
37Exception: Bit shift by negative number
38--- testing: '0' >> 'abc' ---
39int(0)
40--- testing: '0' >> '123abc' ---
41int(0)
42--- testing: '0' >> '123e5' ---
43int(0)
44--- testing: '0' >> '123e5xyz' ---
45int(0)
46--- testing: '0' >> ' 123abc' ---
47int(0)
48--- testing: '0' >> '123 abc' ---
49int(0)
50--- testing: '0' >> '123abc ' ---
51int(0)
52--- testing: '0' >> '3.4a' ---
53int(0)
54--- testing: '0' >> 'a5.9' ---
55int(0)
56--- testing: '65' >> '0' ---
57int(65)
58--- testing: '65' >> '65' ---
59int(0)
60--- testing: '65' >> '-44' ---
61Exception: Bit shift by negative number
62--- testing: '65' >> '1.2' ---
63int(32)
64--- testing: '65' >> '-7.7' ---
65Exception: Bit shift by negative number
66--- testing: '65' >> 'abc' ---
67int(65)
68--- testing: '65' >> '123abc' ---
69int(0)
70--- testing: '65' >> '123e5' ---
71int(0)
72--- testing: '65' >> '123e5xyz' ---
73int(0)
74--- testing: '65' >> ' 123abc' ---
75int(0)
76--- testing: '65' >> '123 abc' ---
77int(0)
78--- testing: '65' >> '123abc ' ---
79int(0)
80--- testing: '65' >> '3.4a' ---
81int(8)
82--- testing: '65' >> 'a5.9' ---
83int(65)
84--- testing: '-44' >> '0' ---
85int(-44)
86--- testing: '-44' >> '65' ---
87int(-1)
88--- testing: '-44' >> '-44' ---
89Exception: Bit shift by negative number
90--- testing: '-44' >> '1.2' ---
91int(-22)
92--- testing: '-44' >> '-7.7' ---
93Exception: Bit shift by negative number
94--- testing: '-44' >> 'abc' ---
95int(-44)
96--- testing: '-44' >> '123abc' ---
97int(-1)
98--- testing: '-44' >> '123e5' ---
99int(-1)
100--- testing: '-44' >> '123e5xyz' ---
101int(-1)
102--- testing: '-44' >> ' 123abc' ---
103int(-1)
104--- testing: '-44' >> '123 abc' ---
105int(-1)
106--- testing: '-44' >> '123abc ' ---
107int(-1)
108--- testing: '-44' >> '3.4a' ---
109int(-6)
110--- testing: '-44' >> 'a5.9' ---
111int(-44)
112--- testing: '1.2' >> '0' ---
113int(1)
114--- testing: '1.2' >> '65' ---
115int(0)
116--- testing: '1.2' >> '-44' ---
117Exception: Bit shift by negative number
118--- testing: '1.2' >> '1.2' ---
119int(0)
120--- testing: '1.2' >> '-7.7' ---
121Exception: Bit shift by negative number
122--- testing: '1.2' >> 'abc' ---
123int(1)
124--- testing: '1.2' >> '123abc' ---
125int(0)
126--- testing: '1.2' >> '123e5' ---
127int(0)
128--- testing: '1.2' >> '123e5xyz' ---
129int(0)
130--- testing: '1.2' >> ' 123abc' ---
131int(0)
132--- testing: '1.2' >> '123 abc' ---
133int(0)
134--- testing: '1.2' >> '123abc ' ---
135int(0)
136--- testing: '1.2' >> '3.4a' ---
137int(0)
138--- testing: '1.2' >> 'a5.9' ---
139int(1)
140--- testing: '-7.7' >> '0' ---
141int(-7)
142--- testing: '-7.7' >> '65' ---
143int(-1)
144--- testing: '-7.7' >> '-44' ---
145Exception: Bit shift by negative number
146--- testing: '-7.7' >> '1.2' ---
147int(-4)
148--- testing: '-7.7' >> '-7.7' ---
149Exception: Bit shift by negative number
150--- testing: '-7.7' >> 'abc' ---
151int(-7)
152--- testing: '-7.7' >> '123abc' ---
153int(-1)
154--- testing: '-7.7' >> '123e5' ---
155int(-1)
156--- testing: '-7.7' >> '123e5xyz' ---
157int(-1)
158--- testing: '-7.7' >> ' 123abc' ---
159int(-1)
160--- testing: '-7.7' >> '123 abc' ---
161int(-1)
162--- testing: '-7.7' >> '123abc ' ---
163int(-1)
164--- testing: '-7.7' >> '3.4a' ---
165int(-1)
166--- testing: '-7.7' >> 'a5.9' ---
167int(-7)
168--- testing: 'abc' >> '0' ---
169int(0)
170--- testing: 'abc' >> '65' ---
171int(0)
172--- testing: 'abc' >> '-44' ---
173Exception: Bit shift by negative number
174--- testing: 'abc' >> '1.2' ---
175int(0)
176--- testing: 'abc' >> '-7.7' ---
177Exception: Bit shift by negative number
178--- testing: 'abc' >> 'abc' ---
179int(0)
180--- testing: 'abc' >> '123abc' ---
181int(0)
182--- testing: 'abc' >> '123e5' ---
183int(0)
184--- testing: 'abc' >> '123e5xyz' ---
185int(0)
186--- testing: 'abc' >> ' 123abc' ---
187int(0)
188--- testing: 'abc' >> '123 abc' ---
189int(0)
190--- testing: 'abc' >> '123abc ' ---
191int(0)
192--- testing: 'abc' >> '3.4a' ---
193int(0)
194--- testing: 'abc' >> 'a5.9' ---
195int(0)
196--- testing: '123abc' >> '0' ---
197int(123)
198--- testing: '123abc' >> '65' ---
199int(0)
200--- testing: '123abc' >> '-44' ---
201Exception: Bit shift by negative number
202--- testing: '123abc' >> '1.2' ---
203int(61)
204--- testing: '123abc' >> '-7.7' ---
205Exception: Bit shift by negative number
206--- testing: '123abc' >> 'abc' ---
207int(123)
208--- testing: '123abc' >> '123abc' ---
209int(0)
210--- testing: '123abc' >> '123e5' ---
211int(0)
212--- testing: '123abc' >> '123e5xyz' ---
213int(0)
214--- testing: '123abc' >> ' 123abc' ---
215int(0)
216--- testing: '123abc' >> '123 abc' ---
217int(0)
218--- testing: '123abc' >> '123abc ' ---
219int(0)
220--- testing: '123abc' >> '3.4a' ---
221int(15)
222--- testing: '123abc' >> 'a5.9' ---
223int(123)
224--- testing: '123e5' >> '0' ---
225int(12300000)
226--- testing: '123e5' >> '65' ---
227int(0)
228--- testing: '123e5' >> '-44' ---
229Exception: Bit shift by negative number
230--- testing: '123e5' >> '1.2' ---
231int(6150000)
232--- testing: '123e5' >> '-7.7' ---
233Exception: Bit shift by negative number
234--- testing: '123e5' >> 'abc' ---
235int(12300000)
236--- testing: '123e5' >> '123abc' ---
237int(0)
238--- testing: '123e5' >> '123e5' ---
239int(0)
240--- testing: '123e5' >> '123e5xyz' ---
241int(0)
242--- testing: '123e5' >> ' 123abc' ---
243int(0)
244--- testing: '123e5' >> '123 abc' ---
245int(0)
246--- testing: '123e5' >> '123abc ' ---
247int(0)
248--- testing: '123e5' >> '3.4a' ---
249int(1537500)
250--- testing: '123e5' >> 'a5.9' ---
251int(12300000)
252--- testing: '123e5xyz' >> '0' ---
253int(12300000)
254--- testing: '123e5xyz' >> '65' ---
255int(0)
256--- testing: '123e5xyz' >> '-44' ---
257Exception: Bit shift by negative number
258--- testing: '123e5xyz' >> '1.2' ---
259int(6150000)
260--- testing: '123e5xyz' >> '-7.7' ---
261Exception: Bit shift by negative number
262--- testing: '123e5xyz' >> 'abc' ---
263int(12300000)
264--- testing: '123e5xyz' >> '123abc' ---
265int(0)
266--- testing: '123e5xyz' >> '123e5' ---
267int(0)
268--- testing: '123e5xyz' >> '123e5xyz' ---
269int(0)
270--- testing: '123e5xyz' >> ' 123abc' ---
271int(0)
272--- testing: '123e5xyz' >> '123 abc' ---
273int(0)
274--- testing: '123e5xyz' >> '123abc ' ---
275int(0)
276--- testing: '123e5xyz' >> '3.4a' ---
277int(1537500)
278--- testing: '123e5xyz' >> 'a5.9' ---
279int(12300000)
280--- testing: ' 123abc' >> '0' ---
281int(123)
282--- testing: ' 123abc' >> '65' ---
283int(0)
284--- testing: ' 123abc' >> '-44' ---
285Exception: Bit shift by negative number
286--- testing: ' 123abc' >> '1.2' ---
287int(61)
288--- testing: ' 123abc' >> '-7.7' ---
289Exception: Bit shift by negative number
290--- testing: ' 123abc' >> 'abc' ---
291int(123)
292--- testing: ' 123abc' >> '123abc' ---
293int(0)
294--- testing: ' 123abc' >> '123e5' ---
295int(0)
296--- testing: ' 123abc' >> '123e5xyz' ---
297int(0)
298--- testing: ' 123abc' >> ' 123abc' ---
299int(0)
300--- testing: ' 123abc' >> '123 abc' ---
301int(0)
302--- testing: ' 123abc' >> '123abc ' ---
303int(0)
304--- testing: ' 123abc' >> '3.4a' ---
305int(15)
306--- testing: ' 123abc' >> 'a5.9' ---
307int(123)
308--- testing: '123 abc' >> '0' ---
309int(123)
310--- testing: '123 abc' >> '65' ---
311int(0)
312--- testing: '123 abc' >> '-44' ---
313Exception: Bit shift by negative number
314--- testing: '123 abc' >> '1.2' ---
315int(61)
316--- testing: '123 abc' >> '-7.7' ---
317Exception: Bit shift by negative number
318--- testing: '123 abc' >> 'abc' ---
319int(123)
320--- testing: '123 abc' >> '123abc' ---
321int(0)
322--- testing: '123 abc' >> '123e5' ---
323int(0)
324--- testing: '123 abc' >> '123e5xyz' ---
325int(0)
326--- testing: '123 abc' >> ' 123abc' ---
327int(0)
328--- testing: '123 abc' >> '123 abc' ---
329int(0)
330--- testing: '123 abc' >> '123abc ' ---
331int(0)
332--- testing: '123 abc' >> '3.4a' ---
333int(15)
334--- testing: '123 abc' >> 'a5.9' ---
335int(123)
336--- testing: '123abc ' >> '0' ---
337int(123)
338--- testing: '123abc ' >> '65' ---
339int(0)
340--- testing: '123abc ' >> '-44' ---
341Exception: Bit shift by negative number
342--- testing: '123abc ' >> '1.2' ---
343int(61)
344--- testing: '123abc ' >> '-7.7' ---
345Exception: Bit shift by negative number
346--- testing: '123abc ' >> 'abc' ---
347int(123)
348--- testing: '123abc ' >> '123abc' ---
349int(0)
350--- testing: '123abc ' >> '123e5' ---
351int(0)
352--- testing: '123abc ' >> '123e5xyz' ---
353int(0)
354--- testing: '123abc ' >> ' 123abc' ---
355int(0)
356--- testing: '123abc ' >> '123 abc' ---
357int(0)
358--- testing: '123abc ' >> '123abc ' ---
359int(0)
360--- testing: '123abc ' >> '3.4a' ---
361int(15)
362--- testing: '123abc ' >> 'a5.9' ---
363int(123)
364--- testing: '3.4a' >> '0' ---
365int(3)
366--- testing: '3.4a' >> '65' ---
367int(0)
368--- testing: '3.4a' >> '-44' ---
369Exception: Bit shift by negative number
370--- testing: '3.4a' >> '1.2' ---
371int(1)
372--- testing: '3.4a' >> '-7.7' ---
373Exception: Bit shift by negative number
374--- testing: '3.4a' >> 'abc' ---
375int(3)
376--- testing: '3.4a' >> '123abc' ---
377int(0)
378--- testing: '3.4a' >> '123e5' ---
379int(0)
380--- testing: '3.4a' >> '123e5xyz' ---
381int(0)
382--- testing: '3.4a' >> ' 123abc' ---
383int(0)
384--- testing: '3.4a' >> '123 abc' ---
385int(0)
386--- testing: '3.4a' >> '123abc ' ---
387int(0)
388--- testing: '3.4a' >> '3.4a' ---
389int(0)
390--- testing: '3.4a' >> 'a5.9' ---
391int(3)
392--- testing: 'a5.9' >> '0' ---
393int(0)
394--- testing: 'a5.9' >> '65' ---
395int(0)
396--- testing: 'a5.9' >> '-44' ---
397Exception: Bit shift by negative number
398--- testing: 'a5.9' >> '1.2' ---
399int(0)
400--- testing: 'a5.9' >> '-7.7' ---
401Exception: Bit shift by negative number
402--- testing: 'a5.9' >> 'abc' ---
403int(0)
404--- testing: 'a5.9' >> '123abc' ---
405int(0)
406--- testing: 'a5.9' >> '123e5' ---
407int(0)
408--- testing: 'a5.9' >> '123e5xyz' ---
409int(0)
410--- testing: 'a5.9' >> ' 123abc' ---
411int(0)
412--- testing: 'a5.9' >> '123 abc' ---
413int(0)
414--- testing: 'a5.9' >> '123abc ' ---
415int(0)
416--- testing: 'a5.9' >> '3.4a' ---
417int(0)
418--- testing: 'a5.9' >> 'a5.9' ---
419int(0)
420===DONE===
421