Skip to content

Commit 19d8e34

Browse files
committed
BitvectorFormulaManager: improve slow rotation test.
Z3 has a regression since the latest version, so lets move the boundary lower.
1 parent 2cb409a commit 19d8e34

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/org/sosy_lab/java_smt/test/BitvectorFormulaManagerTest.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,14 @@ public void bvRotateByConstant() throws SolverException, InterruptedException {
463463

464464
@Test
465465
public void bvRotateByBV() throws SolverException, InterruptedException {
466-
assume()
467-
.withMessage("Princess is too slow for this test")
468-
.that(solver)
469-
.isNotEqualTo(Solvers.PRINCESS);
470-
471-
for (int bitsize : new int[] {8, 13, 25, 31}) {
466+
int[] bitsizes =
467+
switch (solverToUse()) {
468+
case PRINCESS -> new int[] {2, 3}; // Princess is too slow for larger bitvectors
469+
case Z3 -> new int[] {2, 3, 4, 8}; // Z3 is too slow for larger bitvectors since v4.15.0
470+
default -> new int[] {2, 3, 4, 8, 13, 25, 31};
471+
};
472+
473+
for (int bitsize : bitsizes) {
472474
BitvectorFormula zero = bvmgr.makeBitvector(bitsize, 0);
473475
BitvectorFormula a = bvmgr.makeVariable(bitsize, "a" + bitsize);
474476
BitvectorFormula b = bvmgr.makeVariable(bitsize, "b" + bitsize);
@@ -600,6 +602,16 @@ public void bvModulo() throws SolverException, InterruptedException {
600602
assertThatFormula(bvmgr.equal(bvmgr.smodulo(minusTen, minusThree), minusOne)).isTautological();
601603
}
602604

605+
@Test
606+
public void bvModulo2() throws SolverException, InterruptedException {
607+
BitvectorFormula one = bvmgr.makeBitvector(2, 1);
608+
BitvectorFormula two = bvmgr.makeBitvector(2, 2);
609+
BitvectorFormula three = bvmgr.makeBitvector(2, 3);
610+
611+
// check that SMOD works for small bitvectors: 1_2 % 2_2 == 3_2 or 01 % 10 == 11
612+
assertThatFormula(bvmgr.equal(bvmgr.smodulo(one, two), three)).isTautological();
613+
}
614+
603615
@Test
604616
public void bvModuloByZero() throws SolverException, InterruptedException {
605617
BitvectorFormula ten = bvmgr.makeBitvector(8, 10);

0 commit comments

Comments
 (0)