File tree Expand file tree Collapse file tree 2 files changed +66
-0
lines changed
tests/operators/assignments Expand file tree Collapse file tree 2 files changed +66
-0
lines changed Original file line number Diff line number Diff line change 1+ --TEST--
2+ Tests assignments using multiply operator
3+ --SKIPIF--
4+ <?php include (__DIR__ . '/../skipif.inc ' ); ?>
5+ --FILE--
6+ <?php
7+
8+ $ code =<<<ZEP
9+ function mul(int a, int b) {
10+ let a *= b;
11+ let a *= 2;
12+ }
13+ ZEP ;
14+
15+ $ ir = zephir_parse_file ($ code , '(eval code) ' );
16+
17+ echo count ($ ir [0 ]["statements " ]) . "\n" ;
18+
19+ foreach ($ ir [0 ]["statements " ] as $ statement ) {
20+ printf (
21+ "%s %s %s %s %s \n" ,
22+ $ statement ["assignments " ][0 ]["assign-type " ],
23+ $ statement ["assignments " ][0 ]["variable " ],
24+ $ statement ["assignments " ][0 ]["operator " ],
25+ $ statement ["assignments " ][0 ]["expr " ]["type " ],
26+ $ statement ["assignments " ][0 ]["expr " ]["value " ]
27+ );
28+ }
29+ ?>
30+ --EXPECT--
31+ 2
32+ variable a mul-assign variable b
33+ variable a mul-assign int 2
Original file line number Diff line number Diff line change 1+ --TEST--
2+ Tests assignments using substract operator
3+ --SKIPIF--
4+ <?php include (__DIR__ . '/../skipif.inc ' ); ?>
5+ --FILE--
6+ <?php
7+
8+ $ code =<<<ZEP
9+ function sub(int a, int b) {
10+ let a -= b;
11+ let a -= 1;
12+ }
13+ ZEP ;
14+
15+ $ ir = zephir_parse_file ($ code , '(eval code) ' );
16+
17+ echo count ($ ir [0 ]["statements " ]) . "\n" ;
18+
19+ foreach ($ ir [0 ]["statements " ] as $ statement ) {
20+ printf (
21+ "%s %s %s %s %s \n" ,
22+ $ statement ["assignments " ][0 ]["assign-type " ],
23+ $ statement ["assignments " ][0 ]["variable " ],
24+ $ statement ["assignments " ][0 ]["operator " ],
25+ $ statement ["assignments " ][0 ]["expr " ]["type " ],
26+ $ statement ["assignments " ][0 ]["expr " ]["value " ]
27+ );
28+ }
29+ ?>
30+ --EXPECT--
31+ 2
32+ variable a sub-assign variable b
33+ variable a sub-assign int 1
You can’t perform that action at this time.
0 commit comments