xref: /php-ast/tests/assign_ops.phpt (revision 260678d4)
1--TEST--
2Assign op flags
3--FILE--
4<?php
5
6require __DIR__ . '/../util.php';
7
8$code = <<<'PHP'
9<?php
10$a |= $b;
11$a &= $b;
12$a ^= $b;
13$a .= $b;
14$a += $b;
15$a -= $b;
16$a *= $b;
17$a /= $b;
18$a %= $b;
19$a **= $b;
20$a <<= $b;
21$a >>= $b;
22PHP;
23
24echo ast_dump(ast\parse_code($code, $version=70)), "\n";
25
26?>
27--EXPECTF--
28AST_STMT_LIST
29    0: AST_ASSIGN_OP
30        flags: BINARY_BITWISE_OR (%d)
31        var: AST_VAR
32            name: "a"
33        expr: AST_VAR
34            name: "b"
35    1: AST_ASSIGN_OP
36        flags: BINARY_BITWISE_AND (%d)
37        var: AST_VAR
38            name: "a"
39        expr: AST_VAR
40            name: "b"
41    2: AST_ASSIGN_OP
42        flags: BINARY_BITWISE_XOR (%d)
43        var: AST_VAR
44            name: "a"
45        expr: AST_VAR
46            name: "b"
47    3: AST_ASSIGN_OP
48        flags: BINARY_CONCAT (%d)
49        var: AST_VAR
50            name: "a"
51        expr: AST_VAR
52            name: "b"
53    4: AST_ASSIGN_OP
54        flags: BINARY_ADD (%d)
55        var: AST_VAR
56            name: "a"
57        expr: AST_VAR
58            name: "b"
59    5: AST_ASSIGN_OP
60        flags: BINARY_SUB (%d)
61        var: AST_VAR
62            name: "a"
63        expr: AST_VAR
64            name: "b"
65    6: AST_ASSIGN_OP
66        flags: BINARY_MUL (%d)
67        var: AST_VAR
68            name: "a"
69        expr: AST_VAR
70            name: "b"
71    7: AST_ASSIGN_OP
72        flags: BINARY_DIV (%d)
73        var: AST_VAR
74            name: "a"
75        expr: AST_VAR
76            name: "b"
77    8: AST_ASSIGN_OP
78        flags: BINARY_MOD (%d)
79        var: AST_VAR
80            name: "a"
81        expr: AST_VAR
82            name: "b"
83    9: AST_ASSIGN_OP
84        flags: BINARY_POW (%d)
85        var: AST_VAR
86            name: "a"
87        expr: AST_VAR
88            name: "b"
89    10: AST_ASSIGN_OP
90        flags: BINARY_SHIFT_LEFT (%d)
91        var: AST_VAR
92            name: "a"
93        expr: AST_VAR
94            name: "b"
95    11: AST_ASSIGN_OP
96        flags: BINARY_SHIFT_RIGHT (%d)
97        var: AST_VAR
98            name: "a"
99        expr: AST_VAR
100            name: "b"