Skip to content

Commit 804c7a6

Browse files
committed
Update Tests
1 parent e4258aa commit 804c7a6

1 file changed

Lines changed: 22 additions & 33 deletions

File tree

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

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void foldsIntegerArithmeticAndComparisons() {
2727
VCImplication implication = vc("1 + 2 == 3");
2828

2929
assertSimplificationSteps(VCFolding::apply, implication, "3 == 3", "true");
30-
assertFolded("4 > 7", "false");
30+
assertSimplificationSteps(VCFolding::apply, vc("4 > 7"), "false");
3131
}
3232

3333
@Test
@@ -41,52 +41,52 @@ void foldsRealAndMixedNumericExpressions() {
4141

4242
@Test
4343
void leavesDivisionAndModuloByZeroUnchanged() {
44-
assertUnchanged("4 / 0 == 0");
45-
assertUnchanged("4 % 0 == 0");
44+
assertSimplificationSteps(VCFolding::apply, vc("4 / 0 == 0"), "4 / 0 == 0");
45+
assertSimplificationSteps(VCFolding::apply, vc("4 % 0 == 0"), "4 % 0 == 0");
4646
}
4747

4848
@Test
4949
void leavesRealDivisionAndModuloByZeroUnchanged() {
50-
assertUnchanged("4.0 / 0.0 == 0.0");
51-
assertUnchanged("4.0 % 0.0 == 0.0");
50+
assertSimplificationSteps(VCFolding::apply, vc("4.0 / 0.0 == 0.0"), "4.0 / 0.0 == 0.0");
51+
assertSimplificationSteps(VCFolding::apply, vc("4.0 % 0.0 == 0.0"), "4.0 % 0.0 == 0.0");
5252
}
5353

5454
@Test
5555
void foldsBooleanBinaryExpressions() {
56-
assertFolded("true && false", "false");
57-
assertFolded("false --> true", "true");
58-
assertFolded("true != false", "true");
56+
assertSimplificationSteps(VCFolding::apply, vc("true && false"), "false");
57+
assertSimplificationSteps(VCFolding::apply, vc("false --> true"), "true");
58+
assertSimplificationSteps(VCFolding::apply, vc("true != false"), "true");
5959
}
6060

6161
@Test
6262
void foldsBooleanSubexpressionsInsideLargerExpression() {
63-
assertFolded("true && false || ok", "false || ok");
63+
assertSimplificationSteps(VCFolding::apply, vc("true && false || ok"), "false || ok");
6464
}
6565

6666
@Test
6767
void foldsNestedConstantsInsideLargerExpression() {
68-
assertFolded("x > 1 + 2", "x > 3");
69-
assertFolded("x + 1 + 2 > 4", "x + 3 > 4");
68+
assertSimplificationSteps(VCFolding::apply, vc("x > 1 + 2"), "x > 3");
69+
assertSimplificationSteps(VCFolding::apply, vc("x + 1 + 2 > 4"), "x + 3 > 4");
7070
}
7171

7272
@Test
7373
void foldsPartialComparisonsWithoutDroppingSymbolicTerms() {
74-
assertFolded("1 + 2 < x + 4", "3 < x + 4");
74+
assertSimplificationSteps(VCFolding::apply, vc("1 + 2 < x + 4"), "3 < x + 4");
7575
}
7676

7777
@Test
7878
void foldsUnaryExpressions() {
79-
assertFolded("!true", "false");
79+
assertSimplificationSteps(VCFolding::apply, vc("!true"), "false");
8080
VCImplication implication = vc("-3 < 0");
8181

8282
assertSimplificationSteps(VCFolding::apply, implication, "-3 < 0", "true");
8383
}
8484

8585
@Test
8686
void foldsIteExpressions() {
87-
assertFolded("true ? a : b", "a");
88-
assertFolded("false ? a : b", "b");
89-
assertFolded("cond ? b : b", "b");
87+
assertSimplificationSteps(VCFolding::apply, vc("true ? a : b"), "a");
88+
assertSimplificationSteps(VCFolding::apply, vc("false ? a : b"), "b");
89+
assertSimplificationSteps(VCFolding::apply, vc("cond ? b : b"), "b");
9090
}
9191

9292
@Test
@@ -98,16 +98,16 @@ void foldsIteBranchesBeforeComparingThem() {
9898

9999
@Test
100100
void foldsAdjacentIntegerConstants() {
101-
assertFolded("x + 1 - 2", "x - 1");
102-
assertFolded("x - 1 + 2", "x + 1");
103-
assertFolded("x + 1 + 2", "x + 3");
104-
assertFolded("x + 1 - 1", "x");
101+
assertSimplificationSteps(VCFolding::apply, vc("x + 1 - 2"), "x - 1");
102+
assertSimplificationSteps(VCFolding::apply, vc("x - 1 + 2"), "x + 1");
103+
assertSimplificationSteps(VCFolding::apply, vc("x + 1 + 2"), "x + 3");
104+
assertSimplificationSteps(VCFolding::apply, vc("x + 1 - 1"), "x");
105105
}
106106

107107
@Test
108108
void foldsEnumEqualityAndInequality() {
109-
assertFolded("Mode.Photo == Mode.Photo", "true");
110-
assertFolded("Mode.Photo != Mode.Video", "true");
109+
assertSimplificationSteps(VCFolding::apply, vc("Mode.Photo == Mode.Photo"), "true");
110+
assertSimplificationSteps(VCFolding::apply, vc("Mode.Photo != Mode.Video"), "true");
111111
}
112112

113113
@Test
@@ -163,15 +163,4 @@ void recordsOriginWhenFoldingLaterImplication() {
163163
assertEquals("1 + 2 > 0", simplifiedNext.getOrigin().getRefinement().toString());
164164
}
165165

166-
private static void assertFolded(String original, String folded) {
167-
VCImplication implication = vc(original);
168-
169-
assertSimplificationSteps(VCFolding::apply, implication, folded);
170-
}
171-
172-
private static void assertUnchanged(String original) {
173-
VCImplication implication = vc(original);
174-
175-
assertSimplificationSteps(VCFolding::apply, implication, original);
176-
}
177166
}

0 commit comments

Comments
 (0)