143
143
select 1 > 2 > 3, (1 > 2) > 3, 1 > (2 > 3);
144
144
select 1 >= 2 >= 3, (1 >= 2) >= 3, 1 >= (2 >= 3);
146
select 0xF0 | 0x0F | 0x55, (0xF0 | 0x0F) | 0x55, 0xF0 | (0x0F | 0x55);
148
select 0xF5 & 0x5F & 0x55, (0xF5 & 0x5F) & 0x55, 0xF5 & (0x5F & 0x55);
150
select 4 << 3 << 2, (4 << 3) << 2, 4 << (3 << 2);
152
select 256 >> 3 >> 2, (256 >> 3) >> 2, 256 >> (3 >> 2);
154
--echo Testing that & has precedence over |
155
select 0xF0 & 0x0F | 0x55, (0xF0 & 0x0F) | 0x55, 0xF0 & (0x0F | 0x55);
156
select 0x55 | 0xF0 & 0x0F, (0x55 | 0xF0) & 0x0F, 0x55 | (0xF0 & 0x0F);
158
--echo Testing that << has precedence over |
159
select 0x0F << 4 | 0x0F, (0x0F << 4) | 0x0F, 0x0F << (4 | 0x0F);
160
select 0x0F | 0x0F << 4, (0x0F | 0x0F) << 4, 0x0F | (0x0F << 4);
162
--echo Testing that >> has precedence over |
163
select 0xF0 >> 4 | 0xFF, (0xF0 >> 4) | 0xFF, 0xF0 >> (4 | 0xFF);
164
select 0xFF | 0xF0 >> 4, (0xFF | 0xF0) >> 4, 0xFF | (0xF0 >> 4);
166
--echo Testing that << has precedence over &
167
select 0x0F << 4 & 0xF0, (0x0F << 4) & 0xF0, 0x0F << (4 & 0xF0);
168
select 0xF0 & 0x0F << 4, (0xF0 & 0x0F) << 4, 0xF0 & (0x0F << 4);
170
--echo Testing that >> has precedence over &
171
select 0xF0 >> 4 & 0x55, (0xF0 >> 4) & 0x55, 0xF0 >> (4 & 0x55);
172
select 0x0F & 0xF0 >> 4, (0x0F & 0xF0) >> 4, 0x0F & (0xF0 >> 4);
174
--echo Testing that >> and << have the same precedence
175
select 0xFF >> 4 << 2, (0xFF >> 4) << 2, 0xFF >> (4 << 2);
176
select 0x0F << 4 >> 2, (0x0F << 4) >> 2, 0x0F << (4 >> 2);
178
146
--echo Testing that binary + is associative
179
147
select 1 + 2 + 3, (1 + 2) + 3, 1 + (2 + 3);
190
154
select 1 + 2 - 3, (1 + 2) - 3, 1 + (2 - 3);
191
155
select 1 - 2 + 3, (1 - 2) + 3, 1 - (2 + 3);
193
--echo Testing that binary + has precedence over |
194
select 0xF0 + 0x0F | 0x55, (0xF0 + 0x0F) | 0x55, 0xF0 + (0x0F | 0x55);
195
select 0x55 | 0xF0 + 0x0F, (0x55 | 0xF0) + 0x0F, 0x55 | (0xF0 + 0x0F);
197
--echo Testing that binary + has precedence over &
198
select 0xF0 + 0x0F & 0x55, (0xF0 + 0x0F) & 0x55, 0xF0 + (0x0F & 0x55);
199
select 0x55 & 0xF0 + 0x0F, (0x55 & 0xF0) + 0x0F, 0x55 & (0xF0 + 0x0F);
201
--echo Testing that binary + has precedence over <<
202
select 2 + 3 << 4, (2 + 3) << 4, 2 + (3 << 4);
203
select 3 << 4 + 2, (3 << 4) + 2, 3 << (4 + 2);
205
--echo Testing that binary + has precedence over >>
206
select 4 + 3 >> 2, (4 + 3) >> 2, 4 + (3 >> 2);
207
select 3 >> 2 + 1, (3 >> 2) + 1, 3 >> (2 + 1);
209
--echo Testing that binary - has precedence over |
210
select 0xFF - 0x0F | 0x55, (0xFF - 0x0F) | 0x55, 0xFF - (0x0F | 0x55);
211
select 0x55 | 0xFF - 0xF0, (0x55 | 0xFF) - 0xF0, 0x55 | (0xFF - 0xF0);
213
--echo Testing that binary - has precedence over &
214
select 0xFF - 0xF0 & 0x55, (0xFF - 0xF0) & 0x55, 0xFF - (0xF0 & 0x55);
215
select 0x55 & 0xFF - 0xF0, (0x55 & 0xFF) - 0xF0, 0x55 & (0xFF - 0xF0);
217
--echo Testing that binary - has precedence over <<
218
select 16 - 3 << 2, (16 - 3) << 2, 16 - (3 << 2);
219
select 4 << 3 - 2, (4 << 3) - 2, 4 << (3 - 2);
221
--echo Testing that binary - has precedence over >>
222
select 16 - 3 >> 2, (16 - 3) >> 2, 16 - (3 >> 2);
223
select 16 >> 3 - 2, (16 >> 3) - 2, 16 >> (3 - 2);
225
157
--echo Testing that * is associative
226
158
select 2 * 3 * 4, (2 * 3) * 4, 2 * (3 * 4);
228
--echo Testing that * has precedence over |
229
select 2 * 0x40 | 0x0F, (2 * 0x40) | 0x0F, 2 * (0x40 | 0x0F);
230
select 0x0F | 2 * 0x40, (0x0F | 2) * 0x40, 0x0F | (2 * 0x40);
232
--echo Testing that * has precedence over &
233
select 2 * 0x40 & 0x55, (2 * 0x40) & 0x55, 2 * (0x40 & 0x55);
234
select 0xF0 & 2 * 0x40, (0xF0 & 2) * 0x40, 0xF0 & (2 * 0x40);
236
--echo Testing that * has precedence over <<
237
# Actually, can't prove it for the first case,
238
# since << is a multiplication by a power of 2,
239
# and * is associative
240
select 5 * 3 << 4, (5 * 3) << 4, 5 * (3 << 4);
241
select 2 << 3 * 4, (2 << 3) * 4, 2 << (3 * 4);
243
--echo Testing that * has precedence over >>
244
# >> is a multiplication by a (negative) power of 2,
246
select 3 * 4 >> 2, (3 * 4) >> 2, 3 * (4 >> 2);
247
select 4 >> 2 * 3, (4 >> 2) * 3, 4 >> (2 * 3);
249
160
--echo Testing that * has precedence over binary +
250
161
select 2 * 3 + 4, (2 * 3) + 4, 2 * (3 + 4);
251
162
select 2 + 3 * 4, (2 + 3) * 4, 2 + (3 * 4);
257
168
--echo Testing that / is left associative
258
169
select 15 / 5 / 3, (15 / 5) / 3, 15 / (5 / 3);
260
--echo Testing that / has precedence over |
261
select 105 / 5 | 2, (105 / 5) | 2, 105 / (5 | 2);
262
select 105 | 2 / 5, (105 | 2) / 5, 105 | (2 / 5);
264
--echo Testing that / has precedence over &
265
select 105 / 5 & 0x0F, (105 / 5) & 0x0F, 105 / (5 & 0x0F);
266
select 0x0F & 105 / 5, (0x0F & 105) / 5, 0x0F & (105 / 5);
268
--echo Testing that / has precedence over <<
269
select 0x80 / 4 << 2, (0x80 / 4) << 2, 0x80 / (4 << 2);
270
select 0x80 << 4 / 2, (0x80 << 4) / 2, 0x80 << (4 / 2);
272
--echo Testing that / has precedence over >>
273
select 0x80 / 4 >> 2, (0x80 / 4) >> 2, 0x80 / (4 >> 2);
274
select 0x80 >> 4 / 2, (0x80 >> 4) / 2, 0x80 >> (4 / 2);
276
171
--echo Testing that / has precedence over binary +
277
172
select 0x80 / 2 + 2, (0x80 / 2) + 2, 0x80 / (2 + 2);
278
173
select 0x80 + 2 / 2, (0x80 + 2) / 2, 0x80 + (2 / 2);
280
175
--echo Testing that / has precedence over binary -
281
176
select 0x80 / 4 - 2, (0x80 / 4) - 2, 0x80 / (4 - 2);
282
177
select 0x80 - 4 / 2, (0x80 - 4) / 2, 0x80 - (4 / 2);
286
--echo Testing that ^ is associative
287
select 0xFF ^ 0xF0 ^ 0x0F, (0xFF ^ 0xF0) ^ 0x0F, 0xFF ^ (0xF0 ^ 0x0F);
288
select 0xFF ^ 0xF0 ^ 0x55, (0xFF ^ 0xF0) ^ 0x55, 0xFF ^ (0xF0 ^ 0x55);
290
--echo Testing that ^ has precedence over |
291
select 0xFF ^ 0xF0 | 0x0F, (0xFF ^ 0xF0) | 0x0F, 0xFF ^ (0xF0 | 0x0F);
292
select 0xF0 | 0xFF ^ 0xF0, (0xF0 | 0xFF) ^ 0xF0, 0xF0 | (0xFF ^ 0xF0);
294
--echo Testing that ^ has precedence over &
295
select 0xFF ^ 0xF0 & 0x0F, (0xFF ^ 0xF0) & 0x0F, 0xFF ^ (0xF0 & 0x0F);
296
select 0x0F & 0xFF ^ 0xF0, (0x0F & 0xFF) ^ 0xF0, 0x0F & (0xFF ^ 0xF0);
298
--echo Testing that ^ has precedence over <<
299
select 0xFF ^ 0xF0 << 2, (0xFF ^ 0xF0) << 2, 0xFF ^ (0xF0 << 2);
300
select 0x0F << 2 ^ 0xFF, (0x0F << 2) ^ 0xFF, 0x0F << (2 ^ 0xFF);
302
--echo Testing that ^ has precedence over >>
303
select 0xFF ^ 0xF0 >> 2, (0xFF ^ 0xF0) >> 2, 0xFF ^ (0xF0 >> 2);
304
select 0xFF >> 2 ^ 0xF0, (0xFF >> 2) ^ 0xF0, 0xFF >> (2 ^ 0xF0);
306
--echo Testing that ^ has precedence over binary +
307
select 0xFF ^ 0xF0 + 0x0F, (0xFF ^ 0xF0) + 0x0F, 0xFF ^ (0xF0 + 0x0F);
308
select 0x0F + 0xFF ^ 0xF0, (0x0F + 0xFF) ^ 0xF0, 0x0F + (0xFF ^ 0xF0);
310
--echo Testing that ^ has precedence over binary -
311
select 0xFF ^ 0xF0 - 1, (0xFF ^ 0xF0) - 1, 0xFF ^ (0xF0 - 1);
312
select 0x55 - 0x0F ^ 0x55, (0x55 - 0x0F) ^ 0x55, 0x55 - (0x0F ^ 0x55);
314
--echo Testing that ^ has precedence over *
315
select 0xFF ^ 0xF0 * 2, (0xFF ^ 0xF0) * 2, 0xFF ^ (0xF0 * 2);
316
select 2 * 0xFF ^ 0xF0, (2 * 0xFF) ^ 0xF0, 2 * (0xFF ^ 0xF0);
318
--echo Testing that ^ has precedence over /
319
select 0xFF ^ 0xF0 / 2, (0xFF ^ 0xF0) / 2, 0xFF ^ (0xF0 / 2);
320
select 0xF2 / 2 ^ 0xF0, (0xF2 / 2) ^ 0xF0, 0xF2 / (2 ^ 0xF0);
322
--echo Testing that ^ has precedence over %
323
select 0xFF ^ 0xF0 % 0x20, (0xFF ^ 0xF0) % 0x20, 0xFF ^ (0xF0 % 0x20);
324
select 0xFF % 0x20 ^ 0xF0, (0xFF % 0x20) ^ 0xF0, 0xFF % (0x20 ^ 0xF0);
326
--echo Testing that ^ has precedence over DIV
327
select 0xFF ^ 0xF0 DIV 2, (0xFF ^ 0xF0) DIV 2, 0xFF ^ (0xF0 DIV 2);
328
select 0xF2 DIV 2 ^ 0xF0, (0xF2 DIV 2) ^ 0xF0, 0xF2 DIV (2 ^ 0xF0);
330
--echo Testing that ^ has precedence over MOD
331
select 0xFF ^ 0xF0 MOD 0x20, (0xFF ^ 0xF0) MOD 0x20, 0xFF ^ (0xF0 MOD 0x20);
332
select 0xFF MOD 0x20 ^ 0xF0, (0xFF MOD 0x20) ^ 0xF0, 0xFF MOD (0x20 ^ 0xF0);