b3634e91abe7385ed94d11a4f549cc874c42e388
[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: Expr_BinaryOp_BooleanAnd(
25         left: Expr_Variable(
26             name: a
27             comments: array(
28                 0: // boolean ops
29             )
30         )
31         right: Expr_Variable(
32             name: b
33         )
34         comments: array(
35             0: // boolean ops
36         )
37     )
38     1: Expr_BinaryOp_BooleanOr(
39         left: Expr_Variable(
40             name: a
41         )
42         right: Expr_Variable(
43             name: b
44         )
45     )
46     2: Expr_BooleanNot(
47         expr: Expr_Variable(
48             name: a
49         )
50     )
51     3: Expr_BooleanNot(
52         expr: Expr_BooleanNot(
53             expr: Expr_Variable(
54                 name: a
55             )
56         )
57     )
58     4: Expr_BinaryOp_LogicalAnd(
59         left: Expr_Variable(
60             name: a
61             comments: array(
62                 0: // logical ops
63             )
64         )
65         right: Expr_Variable(
66             name: b
67         )
68         comments: array(
69             0: // logical ops
70         )
71     )
72     5: Expr_BinaryOp_LogicalOr(
73         left: Expr_Variable(
74             name: a
75         )
76         right: Expr_Variable(
77             name: b
78         )
79     )
80     6: Expr_BinaryOp_LogicalXor(
81         left: Expr_Variable(
82             name: a
83         )
84         right: Expr_Variable(
85             name: b
86         )
87     )
88     7: Expr_BinaryOp_BooleanOr(
89         left: Expr_BinaryOp_BooleanAnd(
90             left: Expr_Variable(
91                 name: a
92                 comments: array(
93                     0: // precedence
94                 )
95             )
96             right: Expr_Variable(
97                 name: b
98             )
99             comments: array(
100                 0: // precedence
101             )
102         )
103         right: Expr_BinaryOp_BooleanAnd(
104             left: Expr_Variable(
105                 name: c
106             )
107             right: Expr_Variable(
108                 name: d
109             )
110         )
111         comments: array(
112             0: // precedence
113         )
114     )
115     8: Expr_BinaryOp_BooleanAnd(
116         left: Expr_BinaryOp_BooleanAnd(
117             left: Expr_Variable(
118                 name: a
119             )
120             right: Expr_BinaryOp_BooleanOr(
121                 left: Expr_Variable(
122                     name: b
123                 )
124                 right: Expr_Variable(
125                     name: c
126                 )
127             )
128         )
129         right: Expr_Variable(
130             name: d
131         )
132     )
133     9: Expr_Assign(
134         var: Expr_Variable(
135             name: a
136         )
137         expr: Expr_BinaryOp_BooleanOr(
138             left: Expr_Variable(
139                 name: b
140             )
141             right: Expr_Variable(
142                 name: c
143             )
144         )
145     )
146     10: Expr_BinaryOp_LogicalOr(
147         left: Expr_Assign(
148             var: Expr_Variable(
149                 name: a
150             )
151             expr: Expr_Variable(
152                 name: b
153             )
154         )
155         right: Expr_Variable(
156             name: c
157         )
158     )
159 )