@@ -10,60 +10,55 @@ class VCArithmeticSimplificationTest {
1010
1111 @ Test
1212 void simplifiesAdditiveIdentities () {
13- assertSimplificationSteps (simplification :: apply , vc ("x + 0 > 0" ), chain ( expect ( "x > 0" , "x + 0 > 0" ) ));
14- assertSimplificationSteps (simplification :: apply , vc ("0 + x > 0" ), chain ( expect ( "x > 0" , "0 + x > 0" ) ));
15- assertSimplificationSteps (simplification :: apply , vc ("x - 0 > 0" ), chain ( expect ( "x > 0" , "x - 0 > 0" ) ));
16- assertSimplificationSteps (simplification :: apply , vc ("0 - x > 0" ), chain ( expect ( "-x > 0" , "0 - x > 0" ) ));
13+ assertSimplificationSteps (simplification , vc ("x + 0 > 0" ), step ( "x > 0" ));
14+ assertSimplificationSteps (simplification , vc ("0 + x > 0" ), step ( "x > 0" ));
15+ assertSimplificationSteps (simplification , vc ("x - 0 > 0" ), step ( "x > 0" ));
16+ assertSimplificationSteps (simplification , vc ("0 - x > 0" ), step ( "-x > 0" ));
1717 }
1818
1919 @ Test
2020 void simplifiesNegatedAdditionAndSubtraction () {
21- assertSimplificationSteps (simplification :: apply , vc ("x + -x == 0" ), chain ( expect ( "0 == 0" , "x + -x == 0" ) ));
22- assertSimplificationSteps (simplification :: apply , vc ("-x + x == 0" ), chain ( expect ( "0 == 0" , "-x + x == 0" ) ));
23- assertSimplificationSteps (simplification :: apply , vc ("x - x == 0" ), chain ( expect ( "0 == 0" , "x - x == 0" ) ));
24- assertSimplificationSteps (simplification :: apply , vc ("--x == x" ), chain ( expect ( "x == x" , "-(-x) == x" ) ));
25- assertSimplificationSteps (simplification :: apply , vc ("x + -y == 0" ), chain ( expect ( "x - y == 0" , "x + -y == 0" ) ));
26- assertSimplificationSteps (simplification :: apply , vc ("x - -y == 0" ), chain ( expect ( "x + y == 0" , "x - -y == 0" ) ));
21+ assertSimplificationSteps (simplification , vc ("x + -x == 0" ), step ( "0 == 0" ));
22+ assertSimplificationSteps (simplification , vc ("-x + x == 0" ), step ( "0 == 0" ));
23+ assertSimplificationSteps (simplification , vc ("x - x == 0" ), step ( "0 == 0" ));
24+ assertSimplificationSteps (simplification , vc ("--x == x" ), step ( "x == x" ));
25+ assertSimplificationSteps (simplification , vc ("x + -y == 0" ), step ( "x - y == 0" ));
26+ assertSimplificationSteps (simplification , vc ("x - -y == 0" ), step ( "x + y == 0" ));
2727 }
2828
2929 @ Test
3030 void simplifiesMultiplicativeIdentities () {
31- assertSimplificationSteps (simplification :: apply , vc ("x * 1 > 0" ), chain ( expect ( "x > 0" , "x * 1 > 0" ) ));
32- assertSimplificationSteps (simplification :: apply , vc ("1 * x > 0" ), chain ( expect ( "x > 0" , "1 * x > 0" ) ));
33- assertSimplificationSteps (simplification :: apply , vc ("x * 0 == 0" ), chain ( expect ( "0 == 0" , "x * 0 == 0" ) ));
34- assertSimplificationSteps (simplification :: apply , vc ("0 * x == 0" ), chain ( expect ( "0 == 0" , "0 * x == 0" ) ));
35- assertSimplificationSteps (simplification :: apply , vc ("x / 1 > 0" ), chain ( expect ( "x > 0" , "x / 1 > 0" ) ));
36- assertSimplificationSteps (simplification :: apply , vc ("x % 1 == 0" ), chain ( expect ( "0 == 0" , "x % 1 == 0" ) ));
31+ assertSimplificationSteps (simplification , vc ("x * 1 > 0" ), step ( "x > 0" ));
32+ assertSimplificationSteps (simplification , vc ("1 * x > 0" ), step ( "x > 0" ));
33+ assertSimplificationSteps (simplification , vc ("x * 0 == 0" ), step ( "0 == 0" ));
34+ assertSimplificationSteps (simplification , vc ("0 * x == 0" ), step ( "0 == 0" ));
35+ assertSimplificationSteps (simplification , vc ("x / 1 > 0" ), step ( "x > 0" ));
36+ assertSimplificationSteps (simplification , vc ("x % 1 == 0" ), step ( "0 == 0" ));
3737 }
3838
3939 @ Test
4040 void simplifiesGuardedDivisionAndModuloIdentities () {
41- assertSimplificationSteps (simplification ::apply , vc ("x != 0" , "0 / x == 0" ),
42- chain (expect ("x != 0" ), expect ("0 == 0" , "0 / x == 0" )));
43- assertSimplificationSteps (simplification ::apply , vc ("x != 0" , "x / x == 1" ),
44- chain (expect ("x != 0" ), expect ("1 == 1" , "x / x == 1" )));
45- assertSimplificationSteps (simplification ::apply , vc ("0 != x" , "x % x == 0" ),
46- chain (expect ("0 != x" ), expect ("0 == 0" , "x % x == 0" )));
41+ assertSimplificationSteps (simplification , vc ("x != 0" , "0 / x == 0" ), step ("x != 0" , "0 == 0" ));
42+ assertSimplificationSteps (simplification , vc ("x != 0" , "x / x == 1" ), step ("x != 0" , "1 == 1" ));
43+ assertSimplificationSteps (simplification , vc ("0 != x" , "x % x == 0" ), step ("0 != x" , "0 == 0" ));
4744 }
4845
4946 @ Test
5047 void leavesUnguardedDivisionAndModuloIdentitiesUnchanged () {
51- assertSimplificationSteps (simplification :: apply , vc ("0 / x == 0" ), chain ( expect ( "0 / x == 0" ) ));
52- assertSimplificationSteps (simplification :: apply , vc ("x / x == 1" ), chain ( expect ( "x / x == 1" ) ));
53- assertSimplificationSteps (simplification :: apply , vc ("x % x == 0" ), chain ( expect ( "x % x == 0" ) ));
48+ assertSimplificationSteps (simplification , vc ("0 / x == 0" ), step ( "0 / x == 0" ));
49+ assertSimplificationSteps (simplification , vc ("x / x == 1" ), step ( "x / x == 1" ));
50+ assertSimplificationSteps (simplification , vc ("x % x == 0" ), step ( "x % x == 0" ));
5451 }
5552
5653 @ Test
5754 void simplifiesOnlyFirstArithmeticIdentity () {
58- assertSimplificationSteps (simplification ::apply , vc ("x + 0 + 1 > 0" ),
59- chain (expect ("x + 1 > 0" , "x + 0 + 1 > 0" )));
55+ assertSimplificationSteps (simplification , vc ("x + 0 + 1 > 0" ), step ("x + 1 > 0" ));
6056 }
6157
6258 @ Test
6359 void recordsOriginWhenSimplifyingLaterImplication () {
6460 VCImplication implication = vc ("x > 0" , "y + 0 > x" );
6561
66- assertSimplificationSteps (simplification ::apply , implication ,
67- chain (expect ("x > 0" ), expect ("y > x" , "y + 0 > x" )));
62+ assertSimplificationSteps (simplification , implication , step ("x > 0" , "y > x" ));
6863 }
6964}
0 commit comments