@@ -45,7 +45,7 @@ public static void main(String[] args) {
45
45
"test14" , "test15" , "test16" ,
46
46
"test17" , "test18" , "test19" ,
47
47
"test20" , "test21" , "test22" ,
48
- "test23" })
48
+ "test23" , "test24" , "test25" })
49
49
public void runMethod () {
50
50
int a = RunInfo .getRandom ().nextInt ();
51
51
int b = RunInfo .getRandom ().nextInt ();
@@ -63,31 +63,33 @@ public void runMethod() {
63
63
64
64
@ DontCompile
65
65
public void assertResult (int a , int b , int c , int d ) {
66
- Asserts .assertEQ (((a +a ) + (a +a )) , additions (a ));
67
- Asserts .assertEQ (0 , xMinusX (a ));
68
- Asserts .assertEQ (a + 1 + 2 , test1 (a ));
69
- Asserts .assertEQ ((a + 2021 ) + b , test2 (a , b ));
70
- Asserts .assertEQ (a + (b + 2021 ) , test3 (a , b ));
71
- Asserts .assertEQ ((1 - a ) + 2 , test4 (a ));
72
- Asserts .assertEQ ((a - b ) + (c - d ), test5 (a , b , c , d ));
73
- Asserts .assertEQ ((a - b ) + (b + c ), test6 (a , b , c ));
74
- Asserts .assertEQ ((a - b ) + (c + b ), test7 (a , b , c ));
75
- Asserts .assertEQ ((a - b ) + (b - c ), test8 (a , b , c ));
76
- Asserts .assertEQ ((a - b ) + (c - a ), test9 (a , b , c ));
77
- Asserts .assertEQ (a + (0 - b ) , test10 (a , b ));
78
- Asserts .assertEQ ((0 - b ) + a , test11 (a , b ));
79
- Asserts .assertEQ ((a - b ) + b , test12 (a , b ));
80
- Asserts .assertEQ (b + (a - b ) , test13 (a , b ));
81
- Asserts .assertEQ (a + 0 , test14 (a ));
82
- Asserts .assertEQ (0 + a , test15 (a ));
83
- Asserts .assertEQ (a *b + a *c , test16 (a , b , c ));
84
- Asserts .assertEQ (a *b + b *c , test17 (a , b , c ));
85
- Asserts .assertEQ (a *c + b *c , test18 (a , b , c ));
86
- Asserts .assertEQ (a *b + c *a , test19 (a , b , c ));
87
- Asserts .assertEQ ((a - b ) + 210 , test20 (a , b ));
88
- Asserts .assertEQ ((a - b ) + 190 , test21 (a , b ));
89
- Asserts .assertEQ ((a - b ) + 210 , test22 (a , b ));
90
- Asserts .assertEQ ((a - b ) + 190 , test23 (a , b ));
66
+ Asserts .assertEQ (((a +a ) + (a +a )) , additions (a ));
67
+ Asserts .assertEQ (0 , xMinusX (a ));
68
+ Asserts .assertEQ (a + 1 + 2 , test1 (a ));
69
+ Asserts .assertEQ ((a + 2021 ) + b , test2 (a , b ));
70
+ Asserts .assertEQ (a + (b + 2021 ) , test3 (a , b ));
71
+ Asserts .assertEQ ((1 - a ) + 2 , test4 (a ));
72
+ Asserts .assertEQ ((a - b ) + (c - d ) , test5 (a , b , c , d ));
73
+ Asserts .assertEQ ((a - b ) + (b + c ) , test6 (a , b , c ));
74
+ Asserts .assertEQ ((a - b ) + (c + b ) , test7 (a , b , c ));
75
+ Asserts .assertEQ ((a - b ) + (b - c ) , test8 (a , b , c ));
76
+ Asserts .assertEQ ((a - b ) + (c - a ) , test9 (a , b , c ));
77
+ Asserts .assertEQ (a + (0 - b ) , test10 (a , b ));
78
+ Asserts .assertEQ ((0 - b ) + a , test11 (a , b ));
79
+ Asserts .assertEQ ((a - b ) + b , test12 (a , b ));
80
+ Asserts .assertEQ (b + (a - b ) , test13 (a , b ));
81
+ Asserts .assertEQ (a + 0 , test14 (a ));
82
+ Asserts .assertEQ (0 + a , test15 (a ));
83
+ Asserts .assertEQ (a *b + a *c , test16 (a , b , c ));
84
+ Asserts .assertEQ (a *b + b *c , test17 (a , b , c ));
85
+ Asserts .assertEQ (a *c + b *c , test18 (a , b , c ));
86
+ Asserts .assertEQ (a *b + c *a , test19 (a , b , c ));
87
+ Asserts .assertEQ ((a - b ) + 210 , test20 (a , b ));
88
+ Asserts .assertEQ ((a - b ) + 190 , test21 (a , b ));
89
+ Asserts .assertEQ ((a - b ) + 210 , test22 (a , b ));
90
+ Asserts .assertEQ ((a - b ) + 190 , test23 (a , b ));
91
+ Asserts .assertEQ (Math .max (a , b ) + Math .min (a , b ), test24 (a , b ));
92
+ Asserts .assertEQ (Math .min (a , b ) + Math .max (a , b ), test25 (a , b ));
91
93
}
92
94
93
95
@ Test
@@ -293,4 +295,20 @@ public int test22(int x, int y) {
293
295
public int test23 (int x , int y ) {
294
296
return x + (-10 - y ) + 200 ; // transformed to (x - y) + 190;
295
297
}
298
+
299
+ @ Test
300
+ @ IR (failOn = { IRNode .MAX , IRNode .MIN })
301
+ @ IR (counts = { IRNode .ADD , "1" })
302
+ // Checks Math.max(a, b) + Math.min(a, b) => a + b
303
+ public int test24 (int a , int b ) {
304
+ return Math .max (a , b ) + Math .min (a , b );
305
+ }
306
+
307
+ @ Test
308
+ @ IR (failOn = { IRNode .MAX , IRNode .MIN })
309
+ @ IR (counts = { IRNode .ADD , "1" })
310
+ // Checks Math.min(a, b) + Math.max(a, b) => a + b
311
+ public int test25 (int a , int b ) {
312
+ return Math .min (a , b ) + Math .max (a , b );
313
+ }
296
314
}
0 commit comments