Skip to content

Commit 9e76dcf

Browse files
committed
Add More Tests
1 parent 96f9842 commit 9e76dcf

2 files changed

Lines changed: 53 additions & 1 deletion

File tree

liquidjava-verifier/src/test/java/liquidjava/rj_language/opt/VCSimplificationTest.java

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ void simplifyOnceAppliesSubstitutionBeforeBinderSimplification() {
3333
step("true"));
3434
}
3535

36+
@Test
37+
void simplifyCombinesSubstitutionWithArithmeticAndLogicalSimplification() {
38+
assertSimplificationSteps(vc("∀x:int. x == y + 0", "x > 0 && true"), step("y + 0 > 0 && true"),
39+
step("y > 0 && true"), step("y > 0"));
40+
}
41+
3642
@Test
3743
void simplifyOnceAppliesBinderSimplificationBeforeFolding() {
3844
assertSimplificationSteps(vc("∀x:int. true", "1 + 2 > 0"), step("1 + 2 > 0"), step("3 > 0"));
@@ -43,14 +49,25 @@ void simplifyOnceAppliesBinderSimplificationBeforeLogicalSimplification() {
4349
assertSimplificationSteps(vc("∀x:int. true", "y && true"), step("y && true"), step("y"));
4450
}
4551

52+
@Test
53+
void simplifyOnceAppliesBinderSimplificationBeforeArithmeticSimplification() {
54+
assertSimplificationSteps(vc("∀x:int. true", "y + 0 > 0"), step("y + 0 > 0"), step("y > 0"));
55+
}
56+
4657
@Test
4758
void simplifyOnceAppliesFoldingWhenNoSubstitutionIsAvailable() {
4859
assertSimplificationSteps(vc("1 + 2 > 2"), step("3 > 2"), step("true"));
4960
}
5061

5162
@Test
5263
void simplifyOnceAppliesFoldingBeforeArithmeticSimplification() {
53-
assertSimplificationSteps(vc("1 + 2 + x + 0 > 0"), step("3 + x + 0 > 0"));
64+
assertSimplificationSteps(vc("1 + 2 + x + 0 > 0"), step("3 + x + 0 > 0"), step("3 + x > 0"));
65+
}
66+
67+
@Test
68+
void simplifyCombinesFoldingArithmeticAndLogicalSimplification() {
69+
assertSimplificationSteps(vc("1 + 2 + x + 0 == 3 + x"), step("3 + x + 0 == 3 + x"), step("3 + x == 3 + x"),
70+
step("true"));
5471
}
5572

5673
@Test
@@ -63,11 +80,45 @@ void simplifyOnceAppliesArithmeticBeforeLogicalSimplification() {
6380
assertSimplificationSteps(vc("x + 0 == x"), step("x == x"), step("true"));
6481
}
6582

83+
@Test
84+
void simplifyOnceAppliesArithmeticBeforeFoldingOnNextStep() {
85+
assertSimplificationSteps(vc("x - x == 0"), step("0 == 0"), step("true"));
86+
}
87+
6688
@Test
6789
void simplifyOnceAppliesLogicalWhenNoEarlierSimplificationIsAvailable() {
6890
assertSimplificationSteps(vc("x && true"), step("x"));
6991
}
7092

93+
@Test
94+
void simplifyUsesFoldingToEnableSubstitutionOnNextStep() {
95+
assertSimplificationSteps(vc("∀x:int. (x) == 3", "x > 0"), step("x == 3", "x > 0"), step("3 > 0"),
96+
step("true"));
97+
}
98+
99+
@Test
100+
void simplifyUsesArithmeticToEnableSubstitutionOnNextStep() {
101+
assertSimplificationSteps(vc("∀x:int. x + 0 == 3", "x > 0"), step("x == 3", "x > 0"), step("3 > 0"),
102+
step("true"));
103+
}
104+
105+
@Test
106+
void simplifyUsesLogicalSimplificationToEnableSubstitutionOnNextStep() {
107+
assertSimplificationSteps(vc("∀x:int. true && x == 3", "x > 0"), step("x == 3", "x > 0"), step("3 > 0"),
108+
step("true"));
109+
}
110+
111+
@Test
112+
void simplifyUsesFoldingToEnableBinderSimplificationOnNextStep() {
113+
assertSimplificationSteps(vc("∀x:int. 1 > 2", "y > 0"), step("false", "y > 0"), step("true"));
114+
}
115+
116+
@Test
117+
void simplifyUsesArithmeticAndLogicalSimplificationToEnableBinderRemoval() {
118+
assertSimplificationSteps(vc("∀x:int. x + 0 == x", "y > 0"), step("x == x", "y > 0"), step("true", "y > 0"),
119+
step("y > 0"));
120+
}
121+
71122
@Test
72123
void simplifyAppliesLogicalStepsUntilFixedPoint() {
73124
assertSimplificationSteps(vc("x && true && true"), step("x && true"), step("x"));

liquidjava-verifier/src/test/java/liquidjava/utils/VCTestUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ private static void assertSimplificationResult(VCSimplificationResult previous,
6868
private static void assertSimplifiedVC(VCImplication implication, String... expected) {
6969
VCImplication current = implication;
7070
for (int i = 0; i < expected.length; i++) {
71+
assertNotNull(current, "Expected implication " + i + " with refinement " + expected[i]);
7172
assertEquals(Predicate.class, current.getRefinement().getClass(),
7273
"Expected simplified refinement at implication " + i + " to be a plain Predicate");
7374
assertEquals(expected[i], formatRefinement(current),

0 commit comments

Comments
 (0)