@@ -43,13 +43,35 @@ void leavesDivisionAndModuloByZeroUnchanged() {
4343 assertUnchanged ("4 % 0 == 0" );
4444 }
4545
46+ @ Test
47+ void leavesRealDivisionAndModuloByZeroUnchanged () {
48+ assertUnchanged ("4.0 / 0.0 == 0.0" );
49+ assertUnchanged ("4.0 % 0.0 == 0.0" );
50+ }
51+
4652 @ Test
4753 void foldsBooleanBinaryExpressions () {
4854 assertFolded ("true && false" , "false" );
4955 assertFolded ("false --> true" , "true" );
5056 assertFolded ("true != false" , "true" );
5157 }
5258
59+ @ Test
60+ void foldsBooleanSubexpressionsInsideLargerExpression () {
61+ assertFolded ("true && false || ok" , "false || ok" );
62+ }
63+
64+ @ Test
65+ void foldsNestedConstantsInsideLargerExpression () {
66+ assertFolded ("x > 1 + 2" , "x > 3" );
67+ assertFolded ("x + 1 + 2 > 4" , "x + 3 > 4" );
68+ }
69+
70+ @ Test
71+ void foldsPartialComparisonsWithoutDroppingSymbolicTerms () {
72+ assertFolded ("1 + 2 < x + 4" , "3 < x + 4" );
73+ }
74+
5375 @ Test
5476 void foldsUnaryExpressions () {
5577 assertFolded ("!true" , "false" );
@@ -63,6 +85,11 @@ void foldsIteExpressions() {
6385 assertFolded ("cond ? b : b" , "b" );
6486 }
6587
88+ @ Test
89+ void foldsIteBranchesBeforeComparingThem () {
90+ assertFolded ("cond ? 1 + 2 : 3" , "3" );
91+ }
92+
6693 @ Test
6794 void foldsAdjacentIntegerConstants () {
6895 assertFolded ("x + 1 - 2" , "x - 1" );
@@ -89,6 +116,19 @@ void foldsResolvedEnumLiterals() {
89116 assertSimplifiedVC (result , simplified ("true" , "Config.LIMIT == 3" ));
90117 }
91118
119+ @ Test
120+ void foldsResolvedEnumLiteralsInsideLargerExpression () {
121+ Enum limit = new Enum ("Config" , "LIMIT" );
122+ limit .setResolvedLiteral (new LiteralInt (3 ));
123+ BinaryExpression arithmetic = new BinaryExpression (limit , "+" , new LiteralInt (2 ));
124+ VCImplication implication = new VCImplication (
125+ new Predicate (new BinaryExpression (arithmetic , "==" , new LiteralInt (5 ))));
126+
127+ VCImplication result = VCFolding .apply (implication );
128+
129+ assertSimplifiedVC (result , simplified ("true" , "Config.LIMIT + 2 == 5" ));
130+ }
131+
92132 @ Test
93133 void preservesOriginFromExistingSimplifiedImplication () {
94134 VCImplication substituted = VCSubstitution .apply (vc ("∀x:int. x == 1" , "x + 1 + 2 > 0" ));
0 commit comments