@@ -126,18 +126,18 @@ public void testParserError7() throws CryptaParserException {
126
126
public void testParserAND () throws CryptaParserException {
127
127
final ICryptaNode node = parser .parse ("send+more=money; d+e>=y" );
128
128
129
- testPreorder ("; = + send more money >= + d e y " , node );
130
- testPostorder ("send more + money = d e + y >= ; " , node );
131
- testInorder ("send + more = money ; d + e >= y " , node );
129
+ testPreorder ("&& = + send more money >= + d e y " , node );
130
+ testPostorder ("send more + money = d e + y >= && " , node );
131
+ testInorder ("send + more = money && d + e >= y " , node );
132
132
}
133
133
134
134
@ Test
135
135
public void testParserAND2 () throws CryptaParserException {
136
136
final ICryptaNode node = parser .parse ("send+more= money; -send -more= \n -money" );
137
137
138
- testPreorder ("; = + send more money = - - " + ParserTest .ZERO + " send more - " + ParserTest .ZERO + " money " , node );
139
- testPostorder ("send more + money = " + ParserTest .ZERO + " send - more - " + ParserTest .ZERO + " money - = ; " , node );
140
- testInorder ("send + more = money ; " + ParserTest .ZERO + " - send - more = " + ParserTest .ZERO + " - money " , node );
138
+ testPreorder ("&& = + send more money = - - " + ParserTest .ZERO + " send more - " + ParserTest .ZERO + " money " , node );
139
+ testPostorder ("send more + money = " + ParserTest .ZERO + " send - more - " + ParserTest .ZERO + " money - = && " , node );
140
+ testInorder ("send + more = money && " + ParserTest .ZERO + " - send - more = " + ParserTest .ZERO + " - money " , node );
141
141
142
142
}
143
143
@@ -146,35 +146,35 @@ public void testParserAND3() throws CryptaParserException {
146
146
var str = "send + more ^ more = money " ;
147
147
final ICryptaNode node = parser .parse (str + ";" + str );
148
148
var preord = "= + send ^ more more money " ;
149
- testPreorder ("; " + preord + preord , node );
149
+ testPreorder ("&& " + preord + preord , node );
150
150
var postord = "send more more ^ + money =" ;
151
- testPostorder (postord + " " + postord + " ; " , node );
152
- testInorder (str + "; " + str , node );
151
+ testPostorder (postord + " " + postord + " && " , node );
152
+ testInorder (str + "&& " + str , node );
153
153
}
154
154
155
155
@ Test
156
156
public void testParserAND4 () throws CryptaParserException {
157
157
final ICryptaNode node = parser .parse ("send+more=money;; d+e>=y" );
158
158
159
- testPreorder ("; = + send more money >= + d e y " , node );
160
- testPostorder ("send more + money = d e + y >= ; " , node );
161
- testInorder ("send + more = money ; d + e >= y " , node );
159
+ testPreorder ("&& = + send more money >= + d e y " , node );
160
+ testPostorder ("send more + money = d e + y >= && " , node );
161
+ testInorder ("send + more = money && d + e >= y " , node );
162
162
}
163
163
164
164
@ Test
165
165
public void testParserAND5 () throws CryptaParserException {
166
166
final ICryptaNode node = parser .parse ("A = B;; A = B" );
167
- testPreorder ("; = A B = A B " , node );
168
- testPostorder ("A B = A B = ; " , node );
169
- testInorder ("A = B ; A = B " , node );
167
+ testPreorder ("&& = A B = A B " , node );
168
+ testPostorder ("A B = A B = && " , node );
169
+ testInorder ("A = B && A = B " , node );
170
170
}
171
171
172
172
@ Test
173
173
public void testParserAND6 () throws CryptaParserException {
174
174
final ICryptaNode node = parser .parse ("A = B;; A = B;;;;;" );
175
- testPreorder ("; = A B = A B " , node );
176
- testPostorder ("A B = A B = ; " , node );
177
- testInorder ("A = B ; A = B " , node );
175
+ testPreorder ("&& = A B = A B " , node );
176
+ testPostorder ("A B = A B = && " , node );
177
+ testInorder ("A = B && A = B " , node );
178
178
}
179
179
180
180
@ Test
@@ -225,9 +225,9 @@ public void testParserErrorAND7() throws CryptaParserException {
225
225
public void testParserInteger1 () throws CryptaParserException {
226
226
final ICryptaNode node = parser .parse ("send+more='1234';; d+e>=y" );
227
227
228
- testPreorder ("; = + send more '1234' >= + d e y " , node );
229
- testPostorder ("send more + '1234' = d e + y >= ; " , node );
230
- testInorder ("send + more = '1234' ; d + e >= y " , node );
228
+ testPreorder ("&& = + send more '1234' >= + d e y " , node );
229
+ testPostorder ("send more + '1234' = d e + y >= && " , node );
230
+ testInorder ("send + more = '1234' && d + e >= y " , node );
231
231
}
232
232
233
233
@ Test (expected = CryptaParserException .class )
@@ -240,4 +240,184 @@ public void testParserIntegerError2() throws CryptaParserException {
240
240
parser .parse ("send + more >= money; 1 + '12a45' = 3" );
241
241
}
242
242
243
+ @ Test
244
+ public void testParserANDsymbol () throws CryptaParserException {
245
+ final ICryptaNode node = parser .parse ("send+more=money && d+e>=y" );
246
+
247
+ testPreorder ("&& = + send more money >= + d e y " , node );
248
+ testPostorder ("send more + money = d e + y >= && " , node );
249
+ testInorder ("send + more = money && d + e >= y " , node );
250
+ }
251
+
252
+ @ Test
253
+ public void testParserAND2symbol () throws CryptaParserException {
254
+ final ICryptaNode node = parser .parse ("send+more= money&& -send -more= \n -money" );
255
+
256
+ testPreorder ("&& = + send more money = - - " + ParserTest .ZERO + " send more - " + ParserTest .ZERO + " money " , node );
257
+ testPostorder ("send more + money = " + ParserTest .ZERO + " send - more - " + ParserTest .ZERO + " money - = && " , node );
258
+ testInorder ("send + more = money && " + ParserTest .ZERO + " - send - more = " + ParserTest .ZERO + " - money " , node );
259
+
260
+ }
261
+
262
+ @ Test
263
+ public void testParserAND3symbol () throws CryptaParserException {
264
+ var str = "send + more ^ more = money " ;
265
+ final ICryptaNode node = parser .parse (str + "&&" + str );
266
+ var preord = "= + send ^ more more money " ;
267
+ testPreorder ("&& " + preord + preord , node );
268
+ var postord = "send more more ^ + money =" ;
269
+ testPostorder (postord + " " + postord + " && " , node );
270
+ testInorder (str + "&& " + str , node );
271
+ }
272
+
273
+ @ Test
274
+ public void testParserAND4symbol () throws CryptaParserException {
275
+ final ICryptaNode node = parser .parse ("send+more=money&&&& d+e>=y" );
276
+
277
+ testPreorder ("&& = + send more money >= + d e y " , node );
278
+ testPostorder ("send more + money = d e + y >= && " , node );
279
+ testInorder ("send + more = money && d + e >= y " , node );
280
+ }
281
+
282
+ @ Test
283
+ public void testParserAND5symbol () throws CryptaParserException {
284
+ final ICryptaNode node = parser .parse ("A = B&&&& A = B" );
285
+ testPreorder ("&& = A B = A B " , node );
286
+ testPostorder ("A B = A B = && " , node );
287
+ testInorder ("A = B && A = B " , node );
288
+ }
289
+
290
+ @ Test
291
+ public void testParserAND6symbol () throws CryptaParserException {
292
+ final ICryptaNode node = parser .parse ("A = B&&&& A = B&&&&&&&&&&" );
293
+ testPreorder ("&& = A B = A B " , node );
294
+ testPostorder ("A B = A B = && " , node );
295
+ testInorder ("A = B && A = B " , node );
296
+ }
297
+
298
+ @ Test
299
+ public void testParserAND7symbol () throws CryptaParserException {
300
+ final ICryptaNode node = parser .parse ("a=b&&" );
301
+ testPreorder ("= a b " , node );
302
+ testPostorder ("a b = " , node );
303
+ testInorder ("a = b " , node );
304
+ }
305
+
306
+ @ Test
307
+ public void testParserAND8symbol () throws CryptaParserException {
308
+ final ICryptaNode node = parser .parse ("a=b&& b=c ; c=d" );
309
+ testPreorder ("&& = a b && = b c = c d " , node );
310
+ testPostorder ("a b = b c = c d = && && " , node );
311
+ testInorder ("a = b && b = c && c = d " , node );
312
+ }
313
+
314
+ @ Test (expected = CryptaParserException .class )
315
+ public void testParserErrorAND2symbol () throws CryptaParserException {
316
+ parser .parse ("&& a=b" );
317
+ }
318
+
319
+ @ Test (expected = CryptaParserException .class )
320
+ public void testParserErrorAND3symbol () throws CryptaParserException {
321
+ parser .parse ("(A = B&& A = B)" );
322
+ }
323
+
324
+ @ Test (expected = CryptaParserException .class )
325
+ public void testParserErrorAND4symbol () throws CryptaParserException {
326
+ parser .parse ("(A !=&& A = B)" );
327
+ }
328
+
329
+ @ Test (expected = CryptaParserException .class )
330
+ public void testParserErrorAND5symbol () throws CryptaParserException {
331
+ parser .parse ("A !=&& (A = B)" );
332
+ }
333
+
334
+ @ Test (expected = CryptaParserException .class )
335
+ public void testParserErrorAND6symbol () throws CryptaParserException {
336
+ parser .parse ("&&" );
337
+ }
338
+
339
+ @ Test (expected = CryptaParserException .class )
340
+ public void testParserErrorAND7symbol () throws CryptaParserException {
341
+ parser .parse ("&&a=b&& b=c&&" );
342
+ }
343
+
344
+ @ Test (expected = CryptaParserException .class )
345
+ public void testParserErrorAND8symbol () throws CryptaParserException {
346
+ parser .parse ("a=b& b=c" );
347
+ }
348
+
349
+ @ Test (expected = CryptaParserException .class )
350
+ public void testParserErrorAND9symbol () throws CryptaParserException {
351
+ parser .parse ("a=b&&& b=c" );
352
+ }
353
+
354
+ // Test on parse integers
355
+ @ Test
356
+ public void testParserInteger1symbol () throws CryptaParserException {
357
+ final ICryptaNode node = parser .parse ("send+more='1234' && && d+e>=y" );
358
+
359
+ testPreorder ("&& = + send more '1234' >= + d e y " , node );
360
+ testPostorder ("send more + '1234' = d e + y >= && " , node );
361
+ testInorder ("send + more = '1234' && d + e >= y " , node );
362
+ }
363
+
364
+ @ Test (expected = CryptaParserException .class )
365
+ public void testParserIntegerError1symbol () throws CryptaParserException {
366
+ parser .parse ("send + more >= money&&1 + 'aabc' = 3" );
367
+ }
368
+
369
+ @ Test (expected = CryptaParserException .class )
370
+ public void testParserIntegerError2symbol () throws CryptaParserException {
371
+ parser .parse ("send + more >= money&& 1 + '12a45' = 3" );
372
+ }
373
+
374
+ @ Test (expected = CryptaParserException .class )
375
+ public void testParserIntegerError3symbol () throws CryptaParserException {
376
+ parser .parse ("send + more >= money&&1 + '' = 3" );
377
+ }
378
+
379
+ @ Test (expected = CryptaParserException .class )
380
+ public void testParserIntegerError4symbol () throws CryptaParserException {
381
+ parser .parse ("send + more >= money&&1 + \" \" = 3" );
382
+ }
383
+
384
+ @ Test (expected = CryptaParserException .class )
385
+ public void testParserIntegerError5symbol () throws CryptaParserException {
386
+ parser .parse ("send + more >= money&&1 + '\" \" ' = 3" );
387
+ }
388
+
389
+ @ Test (expected = CryptaParserException .class )
390
+ public void testParserIntegerError6symbol () throws CryptaParserException {
391
+ parser .parse ("send + more >= money&&1 + \" ''\" = 3" );
392
+ }
393
+
394
+ @ Test
395
+ public void testParserInteger1symboldoubleticks () throws CryptaParserException {
396
+ final ICryptaNode node = parser .parse ("send+more=\" 1234\" && && d+e>=y" );
397
+
398
+ testPreorder ("&& = + send more '1234' >= + d e y " , node );
399
+ testPostorder ("send more + '1234' = d e + y >= && " , node );
400
+ testInorder ("send + more = '1234' && d + e >= y " , node );
401
+ }
402
+
403
+ @ Test (expected = CryptaParserException .class )
404
+ public void testParserIntegerError1symboldoubleticks () throws CryptaParserException {
405
+ parser .parse ("send + more >= money&&1 + \" aabc\" = 3" );
406
+ }
407
+
408
+ @ Test (expected = CryptaParserException .class )
409
+ public void testParserIntegerError2symboldoubleticks () throws CryptaParserException {
410
+ parser .parse ("send + more >= money&& 1 + \" 12a45\" = 3" );
411
+ }
412
+
413
+ @ Test (expected = CryptaParserException .class )
414
+ public void testParserIntegerError3symboldoubleticks () throws CryptaParserException {
415
+ final ICryptaNode node = parser .parse ("send+more=\" 1234' && && d+e>=y" );
416
+ }
417
+
418
+ @ Test (expected = CryptaParserException .class )
419
+ public void testParserIntegerError4symboldoubleticks () throws CryptaParserException {
420
+ final ICryptaNode node = parser .parse ("send+more='1234\" && && d+e>=y" );
421
+ }
422
+
243
423
}
0 commit comments