6b434565f6b0d7c604d4f8ca5158c018e12e2bfa
[yaffs-website] / vendor / nikic / php-parser / test / code / parser / expr / logic.test
1 Logical operators
2 -----
3 <?php
4
5 // boolean ops
6 $a && $b;
7 $a || $b;
8 !$a;
9 !!$a;
10
11 // logical ops
12 $a and $b;
13 $a or $b;
14 $a xor $b;
15
16 // precedence
17 $a && $b || $c && $d;
18 $a && ($b || $c) && $d;
19
20 $a = $b || $c;
21 $a = $b or $c;
22 -----
23 array(
24     0: Stmt_Expression(
25         expr: Expr_BinaryOp_BooleanAnd(
26             left: Expr_Variable(
27                 name: a
28                 comments: array(
29                     0: // boolean ops
30                 )
31             )
32             right: Expr_Variable(
33                 name: b
34             )
35             comments: array(
36                 0: // boolean ops
37             )
38         )
39         comments: array(
40             0: // boolean ops
41         )
42     )
43     1: Stmt_Expression(
44         expr: Expr_BinaryOp_BooleanOr(
45             left: Expr_Variable(
46                 name: a
47             )
48             right: Expr_Variable(
49                 name: b
50             )
51         )
52     )
53     2: Stmt_Expression(
54         expr: Expr_BooleanNot(
55             expr: Expr_Variable(
56                 name: a
57             )
58         )
59     )
60     3: Stmt_Expression(
61         expr: Expr_BooleanNot(
62             expr: Expr_BooleanNot(
63                 expr: Expr_Variable(
64                     name: a
65                 )
66             )
67         )
68     )
69     4: Stmt_Expression(
70         expr: Expr_BinaryOp_LogicalAnd(
71             left: Expr_Variable(
72                 name: a
73                 comments: array(
74                     0: // logical ops
75                 )
76             )
77             right: Expr_Variable(
78                 name: b
79             )
80             comments: array(
81                 0: // logical ops
82             )
83         )
84         comments: array(
85             0: // logical ops
86         )
87     )
88     5: Stmt_Expression(
89         expr: Expr_BinaryOp_LogicalOr(
90             left: Expr_Variable(
91                 name: a
92             )
93             right: Expr_Variable(
94                 name: b
95             )
96         )
97     )
98     6: Stmt_Expression(
99         expr: Expr_BinaryOp_LogicalXor(
100             left: Expr_Variable(
101                 name: a
102             )
103             right: Expr_Variable(
104                 name: b
105             )
106         )
107     )
108     7: Stmt_Expression(
109         expr: Expr_BinaryOp_BooleanOr(
110             left: Expr_BinaryOp_BooleanAnd(
111                 left: Expr_Variable(
112                     name: a
113                     comments: array(
114                         0: // precedence
115                     )
116                 )
117                 right: Expr_Variable(
118                     name: b
119                 )
120                 comments: array(
121                     0: // precedence
122                 )
123             )
124             right: Expr_BinaryOp_BooleanAnd(
125                 left: Expr_Variable(
126                     name: c
127                 )
128                 right: Expr_Variable(
129                     name: d
130                 )
131             )
132             comments: array(
133                 0: // precedence
134             )
135         )
136         comments: array(
137             0: // precedence
138         )
139     )
140     8: Stmt_Expression(
141         expr: Expr_BinaryOp_BooleanAnd(
142             left: Expr_BinaryOp_BooleanAnd(
143                 left: Expr_Variable(
144                     name: a
145                 )
146                 right: Expr_BinaryOp_BooleanOr(
147                     left: Expr_Variable(
148                         name: b
149                     )
150                     right: Expr_Variable(
151                         name: c
152                     )
153                 )
154             )
155             right: Expr_Variable(
156                 name: d
157             )
158         )
159     )
160     9: Stmt_Expression(
161         expr: Expr_Assign(
162             var: Expr_Variable(
163                 name: a
164             )
165             expr: Expr_BinaryOp_BooleanOr(
166                 left: Expr_Variable(
167                     name: b
168                 )
169                 right: Expr_Variable(
170                     name: c
171                 )
172             )
173         )
174     )
175     10: Stmt_Expression(
176         expr: Expr_BinaryOp_LogicalOr(
177             left: Expr_Assign(
178                 var: Expr_Variable(
179                     name: a
180                 )
181                 expr: Expr_Variable(
182                     name: b
183                 )
184             )
185             right: Expr_Variable(
186                 name: c
187             )
188         )
189     )
190 )