1--TEST--
2Test << operator : 64bit long tests
3--SKIPIF--
4<?php
5if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
6?>
7--FILE--
8<?php
9
10define("MAX_64Bit", 9223372036854775807);
11define("MAX_32Bit", 2147483647);
12define("MIN_64Bit", -9223372036854775807 - 1);
13define("MIN_32Bit", -2147483647 - 1);
14
15$longVals = array(
16    MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit,
17    MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1,
18    MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1
19);
20
21$otherVals = array(0, 1, -1, 7, 9, 65, -44, MAX_32Bit, MAX_64Bit);
22
23error_reporting(E_ERROR);
24
25foreach ($longVals as $longVal) {
26   foreach($otherVals as $otherVal) {
27      echo "--- testing: $longVal << $otherVal ---\n";
28      try {
29        var_dump($longVal<<$otherVal);
30      } catch (ArithmeticError $e) {
31        echo "Exception: " . $e->getMessage() . "\n";
32      }
33   }
34}
35
36foreach ($otherVals as $otherVal) {
37   foreach($longVals as $longVal) {
38      echo "--- testing: $otherVal << $longVal ---\n";
39      try {
40        var_dump($otherVal<<$longVal);
41      } catch (ArithmeticError $e) {
42        echo "Exception: " . $e->getMessage() . "\n";
43      }
44   }
45}
46
47?>
48--EXPECT--
49--- testing: 9223372036854775807 << 0 ---
50int(9223372036854775807)
51--- testing: 9223372036854775807 << 1 ---
52int(-2)
53--- testing: 9223372036854775807 << -1 ---
54Exception: Bit shift by negative number
55--- testing: 9223372036854775807 << 7 ---
56int(-128)
57--- testing: 9223372036854775807 << 9 ---
58int(-512)
59--- testing: 9223372036854775807 << 65 ---
60int(0)
61--- testing: 9223372036854775807 << -44 ---
62Exception: Bit shift by negative number
63--- testing: 9223372036854775807 << 2147483647 ---
64int(0)
65--- testing: 9223372036854775807 << 9223372036854775807 ---
66int(0)
67--- testing: -9223372036854775808 << 0 ---
68int(-9223372036854775808)
69--- testing: -9223372036854775808 << 1 ---
70int(0)
71--- testing: -9223372036854775808 << -1 ---
72Exception: Bit shift by negative number
73--- testing: -9223372036854775808 << 7 ---
74int(0)
75--- testing: -9223372036854775808 << 9 ---
76int(0)
77--- testing: -9223372036854775808 << 65 ---
78int(0)
79--- testing: -9223372036854775808 << -44 ---
80Exception: Bit shift by negative number
81--- testing: -9223372036854775808 << 2147483647 ---
82int(0)
83--- testing: -9223372036854775808 << 9223372036854775807 ---
84int(0)
85--- testing: 2147483647 << 0 ---
86int(2147483647)
87--- testing: 2147483647 << 1 ---
88int(4294967294)
89--- testing: 2147483647 << -1 ---
90Exception: Bit shift by negative number
91--- testing: 2147483647 << 7 ---
92int(274877906816)
93--- testing: 2147483647 << 9 ---
94int(1099511627264)
95--- testing: 2147483647 << 65 ---
96int(0)
97--- testing: 2147483647 << -44 ---
98Exception: Bit shift by negative number
99--- testing: 2147483647 << 2147483647 ---
100int(0)
101--- testing: 2147483647 << 9223372036854775807 ---
102int(0)
103--- testing: -2147483648 << 0 ---
104int(-2147483648)
105--- testing: -2147483648 << 1 ---
106int(-4294967296)
107--- testing: -2147483648 << -1 ---
108Exception: Bit shift by negative number
109--- testing: -2147483648 << 7 ---
110int(-274877906944)
111--- testing: -2147483648 << 9 ---
112int(-1099511627776)
113--- testing: -2147483648 << 65 ---
114int(0)
115--- testing: -2147483648 << -44 ---
116Exception: Bit shift by negative number
117--- testing: -2147483648 << 2147483647 ---
118int(0)
119--- testing: -2147483648 << 9223372036854775807 ---
120int(0)
121--- testing: 9223372034707292160 << 0 ---
122int(9223372034707292160)
123--- testing: 9223372034707292160 << 1 ---
124int(-4294967296)
125--- testing: 9223372034707292160 << -1 ---
126Exception: Bit shift by negative number
127--- testing: 9223372034707292160 << 7 ---
128int(-274877906944)
129--- testing: 9223372034707292160 << 9 ---
130int(-1099511627776)
131--- testing: 9223372034707292160 << 65 ---
132int(0)
133--- testing: 9223372034707292160 << -44 ---
134Exception: Bit shift by negative number
135--- testing: 9223372034707292160 << 2147483647 ---
136int(0)
137--- testing: 9223372034707292160 << 9223372036854775807 ---
138int(0)
139--- testing: -9223372034707292160 << 0 ---
140int(-9223372034707292160)
141--- testing: -9223372034707292160 << 1 ---
142int(4294967296)
143--- testing: -9223372034707292160 << -1 ---
144Exception: Bit shift by negative number
145--- testing: -9223372034707292160 << 7 ---
146int(274877906944)
147--- testing: -9223372034707292160 << 9 ---
148int(1099511627776)
149--- testing: -9223372034707292160 << 65 ---
150int(0)
151--- testing: -9223372034707292160 << -44 ---
152Exception: Bit shift by negative number
153--- testing: -9223372034707292160 << 2147483647 ---
154int(0)
155--- testing: -9223372034707292160 << 9223372036854775807 ---
156int(0)
157--- testing: 2147483648 << 0 ---
158int(2147483648)
159--- testing: 2147483648 << 1 ---
160int(4294967296)
161--- testing: 2147483648 << -1 ---
162Exception: Bit shift by negative number
163--- testing: 2147483648 << 7 ---
164int(274877906944)
165--- testing: 2147483648 << 9 ---
166int(1099511627776)
167--- testing: 2147483648 << 65 ---
168int(0)
169--- testing: 2147483648 << -44 ---
170Exception: Bit shift by negative number
171--- testing: 2147483648 << 2147483647 ---
172int(0)
173--- testing: 2147483648 << 9223372036854775807 ---
174int(0)
175--- testing: -2147483649 << 0 ---
176int(-2147483649)
177--- testing: -2147483649 << 1 ---
178int(-4294967298)
179--- testing: -2147483649 << -1 ---
180Exception: Bit shift by negative number
181--- testing: -2147483649 << 7 ---
182int(-274877907072)
183--- testing: -2147483649 << 9 ---
184int(-1099511628288)
185--- testing: -2147483649 << 65 ---
186int(0)
187--- testing: -2147483649 << -44 ---
188Exception: Bit shift by negative number
189--- testing: -2147483649 << 2147483647 ---
190int(0)
191--- testing: -2147483649 << 9223372036854775807 ---
192int(0)
193--- testing: 4294967294 << 0 ---
194int(4294967294)
195--- testing: 4294967294 << 1 ---
196int(8589934588)
197--- testing: 4294967294 << -1 ---
198Exception: Bit shift by negative number
199--- testing: 4294967294 << 7 ---
200int(549755813632)
201--- testing: 4294967294 << 9 ---
202int(2199023254528)
203--- testing: 4294967294 << 65 ---
204int(0)
205--- testing: 4294967294 << -44 ---
206Exception: Bit shift by negative number
207--- testing: 4294967294 << 2147483647 ---
208int(0)
209--- testing: 4294967294 << 9223372036854775807 ---
210int(0)
211--- testing: 4294967295 << 0 ---
212int(4294967295)
213--- testing: 4294967295 << 1 ---
214int(8589934590)
215--- testing: 4294967295 << -1 ---
216Exception: Bit shift by negative number
217--- testing: 4294967295 << 7 ---
218int(549755813760)
219--- testing: 4294967295 << 9 ---
220int(2199023255040)
221--- testing: 4294967295 << 65 ---
222int(0)
223--- testing: 4294967295 << -44 ---
224Exception: Bit shift by negative number
225--- testing: 4294967295 << 2147483647 ---
226int(0)
227--- testing: 4294967295 << 9223372036854775807 ---
228int(0)
229--- testing: 4294967293 << 0 ---
230int(4294967293)
231--- testing: 4294967293 << 1 ---
232int(8589934586)
233--- testing: 4294967293 << -1 ---
234Exception: Bit shift by negative number
235--- testing: 4294967293 << 7 ---
236int(549755813504)
237--- testing: 4294967293 << 9 ---
238int(2199023254016)
239--- testing: 4294967293 << 65 ---
240int(0)
241--- testing: 4294967293 << -44 ---
242Exception: Bit shift by negative number
243--- testing: 4294967293 << 2147483647 ---
244int(0)
245--- testing: 4294967293 << 9223372036854775807 ---
246int(0)
247--- testing: 9223372036854775806 << 0 ---
248int(9223372036854775806)
249--- testing: 9223372036854775806 << 1 ---
250int(-4)
251--- testing: 9223372036854775806 << -1 ---
252Exception: Bit shift by negative number
253--- testing: 9223372036854775806 << 7 ---
254int(-256)
255--- testing: 9223372036854775806 << 9 ---
256int(-1024)
257--- testing: 9223372036854775806 << 65 ---
258int(0)
259--- testing: 9223372036854775806 << -44 ---
260Exception: Bit shift by negative number
261--- testing: 9223372036854775806 << 2147483647 ---
262int(0)
263--- testing: 9223372036854775806 << 9223372036854775807 ---
264int(0)
265--- testing: 9.2233720368548E+18 << 0 ---
266int(-9223372036854775808)
267--- testing: 9.2233720368548E+18 << 1 ---
268int(0)
269--- testing: 9.2233720368548E+18 << -1 ---
270Exception: Bit shift by negative number
271--- testing: 9.2233720368548E+18 << 7 ---
272int(0)
273--- testing: 9.2233720368548E+18 << 9 ---
274int(0)
275--- testing: 9.2233720368548E+18 << 65 ---
276int(0)
277--- testing: 9.2233720368548E+18 << -44 ---
278Exception: Bit shift by negative number
279--- testing: 9.2233720368548E+18 << 2147483647 ---
280int(0)
281--- testing: 9.2233720368548E+18 << 9223372036854775807 ---
282int(0)
283--- testing: -9223372036854775807 << 0 ---
284int(-9223372036854775807)
285--- testing: -9223372036854775807 << 1 ---
286int(2)
287--- testing: -9223372036854775807 << -1 ---
288Exception: Bit shift by negative number
289--- testing: -9223372036854775807 << 7 ---
290int(128)
291--- testing: -9223372036854775807 << 9 ---
292int(512)
293--- testing: -9223372036854775807 << 65 ---
294int(0)
295--- testing: -9223372036854775807 << -44 ---
296Exception: Bit shift by negative number
297--- testing: -9223372036854775807 << 2147483647 ---
298int(0)
299--- testing: -9223372036854775807 << 9223372036854775807 ---
300int(0)
301--- testing: -9.2233720368548E+18 << 0 ---
302int(-9223372036854775808)
303--- testing: -9.2233720368548E+18 << 1 ---
304int(0)
305--- testing: -9.2233720368548E+18 << -1 ---
306Exception: Bit shift by negative number
307--- testing: -9.2233720368548E+18 << 7 ---
308int(0)
309--- testing: -9.2233720368548E+18 << 9 ---
310int(0)
311--- testing: -9.2233720368548E+18 << 65 ---
312int(0)
313--- testing: -9.2233720368548E+18 << -44 ---
314Exception: Bit shift by negative number
315--- testing: -9.2233720368548E+18 << 2147483647 ---
316int(0)
317--- testing: -9.2233720368548E+18 << 9223372036854775807 ---
318int(0)
319--- testing: 0 << 9223372036854775807 ---
320int(0)
321--- testing: 0 << -9223372036854775808 ---
322Exception: Bit shift by negative number
323--- testing: 0 << 2147483647 ---
324int(0)
325--- testing: 0 << -2147483648 ---
326Exception: Bit shift by negative number
327--- testing: 0 << 9223372034707292160 ---
328int(0)
329--- testing: 0 << -9223372034707292160 ---
330Exception: Bit shift by negative number
331--- testing: 0 << 2147483648 ---
332int(0)
333--- testing: 0 << -2147483649 ---
334Exception: Bit shift by negative number
335--- testing: 0 << 4294967294 ---
336int(0)
337--- testing: 0 << 4294967295 ---
338int(0)
339--- testing: 0 << 4294967293 ---
340int(0)
341--- testing: 0 << 9223372036854775806 ---
342int(0)
343--- testing: 0 << 9.2233720368548E+18 ---
344Exception: Bit shift by negative number
345--- testing: 0 << -9223372036854775807 ---
346Exception: Bit shift by negative number
347--- testing: 0 << -9.2233720368548E+18 ---
348Exception: Bit shift by negative number
349--- testing: 1 << 9223372036854775807 ---
350int(0)
351--- testing: 1 << -9223372036854775808 ---
352Exception: Bit shift by negative number
353--- testing: 1 << 2147483647 ---
354int(0)
355--- testing: 1 << -2147483648 ---
356Exception: Bit shift by negative number
357--- testing: 1 << 9223372034707292160 ---
358int(0)
359--- testing: 1 << -9223372034707292160 ---
360Exception: Bit shift by negative number
361--- testing: 1 << 2147483648 ---
362int(0)
363--- testing: 1 << -2147483649 ---
364Exception: Bit shift by negative number
365--- testing: 1 << 4294967294 ---
366int(0)
367--- testing: 1 << 4294967295 ---
368int(0)
369--- testing: 1 << 4294967293 ---
370int(0)
371--- testing: 1 << 9223372036854775806 ---
372int(0)
373--- testing: 1 << 9.2233720368548E+18 ---
374Exception: Bit shift by negative number
375--- testing: 1 << -9223372036854775807 ---
376Exception: Bit shift by negative number
377--- testing: 1 << -9.2233720368548E+18 ---
378Exception: Bit shift by negative number
379--- testing: -1 << 9223372036854775807 ---
380int(0)
381--- testing: -1 << -9223372036854775808 ---
382Exception: Bit shift by negative number
383--- testing: -1 << 2147483647 ---
384int(0)
385--- testing: -1 << -2147483648 ---
386Exception: Bit shift by negative number
387--- testing: -1 << 9223372034707292160 ---
388int(0)
389--- testing: -1 << -9223372034707292160 ---
390Exception: Bit shift by negative number
391--- testing: -1 << 2147483648 ---
392int(0)
393--- testing: -1 << -2147483649 ---
394Exception: Bit shift by negative number
395--- testing: -1 << 4294967294 ---
396int(0)
397--- testing: -1 << 4294967295 ---
398int(0)
399--- testing: -1 << 4294967293 ---
400int(0)
401--- testing: -1 << 9223372036854775806 ---
402int(0)
403--- testing: -1 << 9.2233720368548E+18 ---
404Exception: Bit shift by negative number
405--- testing: -1 << -9223372036854775807 ---
406Exception: Bit shift by negative number
407--- testing: -1 << -9.2233720368548E+18 ---
408Exception: Bit shift by negative number
409--- testing: 7 << 9223372036854775807 ---
410int(0)
411--- testing: 7 << -9223372036854775808 ---
412Exception: Bit shift by negative number
413--- testing: 7 << 2147483647 ---
414int(0)
415--- testing: 7 << -2147483648 ---
416Exception: Bit shift by negative number
417--- testing: 7 << 9223372034707292160 ---
418int(0)
419--- testing: 7 << -9223372034707292160 ---
420Exception: Bit shift by negative number
421--- testing: 7 << 2147483648 ---
422int(0)
423--- testing: 7 << -2147483649 ---
424Exception: Bit shift by negative number
425--- testing: 7 << 4294967294 ---
426int(0)
427--- testing: 7 << 4294967295 ---
428int(0)
429--- testing: 7 << 4294967293 ---
430int(0)
431--- testing: 7 << 9223372036854775806 ---
432int(0)
433--- testing: 7 << 9.2233720368548E+18 ---
434Exception: Bit shift by negative number
435--- testing: 7 << -9223372036854775807 ---
436Exception: Bit shift by negative number
437--- testing: 7 << -9.2233720368548E+18 ---
438Exception: Bit shift by negative number
439--- testing: 9 << 9223372036854775807 ---
440int(0)
441--- testing: 9 << -9223372036854775808 ---
442Exception: Bit shift by negative number
443--- testing: 9 << 2147483647 ---
444int(0)
445--- testing: 9 << -2147483648 ---
446Exception: Bit shift by negative number
447--- testing: 9 << 9223372034707292160 ---
448int(0)
449--- testing: 9 << -9223372034707292160 ---
450Exception: Bit shift by negative number
451--- testing: 9 << 2147483648 ---
452int(0)
453--- testing: 9 << -2147483649 ---
454Exception: Bit shift by negative number
455--- testing: 9 << 4294967294 ---
456int(0)
457--- testing: 9 << 4294967295 ---
458int(0)
459--- testing: 9 << 4294967293 ---
460int(0)
461--- testing: 9 << 9223372036854775806 ---
462int(0)
463--- testing: 9 << 9.2233720368548E+18 ---
464Exception: Bit shift by negative number
465--- testing: 9 << -9223372036854775807 ---
466Exception: Bit shift by negative number
467--- testing: 9 << -9.2233720368548E+18 ---
468Exception: Bit shift by negative number
469--- testing: 65 << 9223372036854775807 ---
470int(0)
471--- testing: 65 << -9223372036854775808 ---
472Exception: Bit shift by negative number
473--- testing: 65 << 2147483647 ---
474int(0)
475--- testing: 65 << -2147483648 ---
476Exception: Bit shift by negative number
477--- testing: 65 << 9223372034707292160 ---
478int(0)
479--- testing: 65 << -9223372034707292160 ---
480Exception: Bit shift by negative number
481--- testing: 65 << 2147483648 ---
482int(0)
483--- testing: 65 << -2147483649 ---
484Exception: Bit shift by negative number
485--- testing: 65 << 4294967294 ---
486int(0)
487--- testing: 65 << 4294967295 ---
488int(0)
489--- testing: 65 << 4294967293 ---
490int(0)
491--- testing: 65 << 9223372036854775806 ---
492int(0)
493--- testing: 65 << 9.2233720368548E+18 ---
494Exception: Bit shift by negative number
495--- testing: 65 << -9223372036854775807 ---
496Exception: Bit shift by negative number
497--- testing: 65 << -9.2233720368548E+18 ---
498Exception: Bit shift by negative number
499--- testing: -44 << 9223372036854775807 ---
500int(0)
501--- testing: -44 << -9223372036854775808 ---
502Exception: Bit shift by negative number
503--- testing: -44 << 2147483647 ---
504int(0)
505--- testing: -44 << -2147483648 ---
506Exception: Bit shift by negative number
507--- testing: -44 << 9223372034707292160 ---
508int(0)
509--- testing: -44 << -9223372034707292160 ---
510Exception: Bit shift by negative number
511--- testing: -44 << 2147483648 ---
512int(0)
513--- testing: -44 << -2147483649 ---
514Exception: Bit shift by negative number
515--- testing: -44 << 4294967294 ---
516int(0)
517--- testing: -44 << 4294967295 ---
518int(0)
519--- testing: -44 << 4294967293 ---
520int(0)
521--- testing: -44 << 9223372036854775806 ---
522int(0)
523--- testing: -44 << 9.2233720368548E+18 ---
524Exception: Bit shift by negative number
525--- testing: -44 << -9223372036854775807 ---
526Exception: Bit shift by negative number
527--- testing: -44 << -9.2233720368548E+18 ---
528Exception: Bit shift by negative number
529--- testing: 2147483647 << 9223372036854775807 ---
530int(0)
531--- testing: 2147483647 << -9223372036854775808 ---
532Exception: Bit shift by negative number
533--- testing: 2147483647 << 2147483647 ---
534int(0)
535--- testing: 2147483647 << -2147483648 ---
536Exception: Bit shift by negative number
537--- testing: 2147483647 << 9223372034707292160 ---
538int(0)
539--- testing: 2147483647 << -9223372034707292160 ---
540Exception: Bit shift by negative number
541--- testing: 2147483647 << 2147483648 ---
542int(0)
543--- testing: 2147483647 << -2147483649 ---
544Exception: Bit shift by negative number
545--- testing: 2147483647 << 4294967294 ---
546int(0)
547--- testing: 2147483647 << 4294967295 ---
548int(0)
549--- testing: 2147483647 << 4294967293 ---
550int(0)
551--- testing: 2147483647 << 9223372036854775806 ---
552int(0)
553--- testing: 2147483647 << 9.2233720368548E+18 ---
554Exception: Bit shift by negative number
555--- testing: 2147483647 << -9223372036854775807 ---
556Exception: Bit shift by negative number
557--- testing: 2147483647 << -9.2233720368548E+18 ---
558Exception: Bit shift by negative number
559--- testing: 9223372036854775807 << 9223372036854775807 ---
560int(0)
561--- testing: 9223372036854775807 << -9223372036854775808 ---
562Exception: Bit shift by negative number
563--- testing: 9223372036854775807 << 2147483647 ---
564int(0)
565--- testing: 9223372036854775807 << -2147483648 ---
566Exception: Bit shift by negative number
567--- testing: 9223372036854775807 << 9223372034707292160 ---
568int(0)
569--- testing: 9223372036854775807 << -9223372034707292160 ---
570Exception: Bit shift by negative number
571--- testing: 9223372036854775807 << 2147483648 ---
572int(0)
573--- testing: 9223372036854775807 << -2147483649 ---
574Exception: Bit shift by negative number
575--- testing: 9223372036854775807 << 4294967294 ---
576int(0)
577--- testing: 9223372036854775807 << 4294967295 ---
578int(0)
579--- testing: 9223372036854775807 << 4294967293 ---
580int(0)
581--- testing: 9223372036854775807 << 9223372036854775806 ---
582int(0)
583--- testing: 9223372036854775807 << 9.2233720368548E+18 ---
584Exception: Bit shift by negative number
585--- testing: 9223372036854775807 << -9223372036854775807 ---
586Exception: Bit shift by negative number
587--- testing: 9223372036854775807 << -9.2233720368548E+18 ---
588Exception: Bit shift by negative number
589