File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ --TEST--
2+ Tests bitwise operators
3+ --SKIPIF--
4+ <?php include (__DIR__ . '/../skipif.inc ' ); ?>
5+ --FILE--
6+ <?php
7+
8+ $ code =<<<ZEP
9+ function bitwise() {
10+ let a = 0x01 << 1;
11+ let a = 0xF0 >> 1;
12+ let a = 0x01 | 0x02;
13+ let a = 0x03 & 0x01;
14+ let a = 0x03 ^ 0x02;
15+ let a = ~ 0x01;
16+ }
17+ ZEP ;
18+
19+ $ ir = zephir_parse_file ($ code , '(eval code) ' );
20+
21+ echo count ($ ir [0 ]["statements " ]) . "\n" ;
22+
23+ foreach ($ ir [0 ]["statements " ] as $ statement ) {
24+ $ expr = $ statement ["assignments " ][0 ]["expr " ];
25+ $ parts = [
26+ $ expr ["left " ]["type " ],
27+ $ expr ["left " ]["value " ],
28+ $ expr ["type " ]
29+ ];
30+
31+ if (isset ($ expr ["right " ])) {
32+ $ parts [] = $ expr ["right " ]["type " ];
33+ $ parts [] = $ expr ["right " ]["value " ];
34+ }
35+
36+ echo implode (" " , $ parts ) . "\n" ;
37+ }
38+ ?>
39+ --EXPECT--
40+ 6
41+ int 0x01 bitwise_shiftleft int 1
42+ int 0xF0 bitwise_shiftright int 1
43+ int 0x01 bitwise_or int 0x02
44+ int 0x03 bitwise_and int 0x01
45+ int 0x03 bitwise_xor int 0x02
46+ int 0x01 bitwise_not
You can’t perform that action at this time.
0 commit comments