diff --git a/lib/ivy.xml b/lib/ivy.xml index fb434116d5..488168c761 100644 --- a/lib/ivy.xml +++ b/lib/ivy.xml @@ -84,14 +84,14 @@ SPDX-License-Identifier: Apache-2.0 - + - + - + @@ -102,7 +102,7 @@ SPDX-License-Identifier: Apache-2.0 - + @@ -119,8 +119,8 @@ SPDX-License-Identifier: Apache-2.0 - - + + @@ -129,11 +129,11 @@ SPDX-License-Identifier: Apache-2.0 - + - + @@ -143,7 +143,7 @@ SPDX-License-Identifier: Apache-2.0 - + @@ -160,14 +160,14 @@ SPDX-License-Identifier: Apache-2.0 - - + + - + diff --git a/src/org/sosy_lab/java_smt/basicimpl/AbstractSolverContext.java b/src/org/sosy_lab/java_smt/basicimpl/AbstractSolverContext.java index ab49b14cfc..f071b00d29 100644 --- a/src/org/sosy_lab/java_smt/basicimpl/AbstractSolverContext.java +++ b/src/org/sosy_lab/java_smt/basicimpl/AbstractSolverContext.java @@ -35,6 +35,7 @@ public final FormulaManager getFormulaManager() { return fmgr; } + @SuppressWarnings("resource") @Override public final ProverEnvironment newProverEnvironment(ProverOptions... options) { ProverEnvironment out = newProverEnvironment0(toSet(options)); diff --git a/src/org/sosy_lab/java_smt/example/FormulaClassifier.java b/src/org/sosy_lab/java_smt/example/FormulaClassifier.java index da96744bc2..e133ad8151 100644 --- a/src/org/sosy_lab/java_smt/example/FormulaClassifier.java +++ b/src/org/sosy_lab/java_smt/example/FormulaClassifier.java @@ -294,7 +294,7 @@ public Integer visitFunction( nonLinearArithmetic = true; return allArgLevel + 1; } - // $FALL-THROUGH$ + // $FALL-THROUGH$ default: if (pFunctionDeclaration.getType().isBooleanType()) { if (EnumSet.of( diff --git a/src/org/sosy_lab/java_smt/test/BitvectorFormulaManagerTest.java b/src/org/sosy_lab/java_smt/test/BitvectorFormulaManagerTest.java index 8ab062564e..bc29fc0f92 100644 --- a/src/org/sosy_lab/java_smt/test/BitvectorFormulaManagerTest.java +++ b/src/org/sosy_lab/java_smt/test/BitvectorFormulaManagerTest.java @@ -10,7 +10,6 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; -import static com.google.common.truth.Truth.assert_; import static com.google.common.truth.TruthJUnit.assume; import static org.junit.Assert.assertThrows; import static org.sosy_lab.java_smt.test.ProverEnvironmentSubject.assertThat; @@ -534,11 +533,9 @@ public void bvInRange() throws SolverException, InterruptedException { @SuppressWarnings("CheckReturnValue") public void bvOutOfRange() { for (int[] sizeAndValue : new int[][] {{4, 32}, {4, -9}, {8, 300}, {8, -160}}) { - try { - bvmgr.makeBitvector(sizeAndValue[0], sizeAndValue[1]); - assert_().fail(); - } catch (IllegalArgumentException expected) { - } + assertThrows( + IllegalArgumentException.class, + () -> bvmgr.makeBitvector(sizeAndValue[0], sizeAndValue[1])); } for (int size : new int[] {4, 6, 8, 10, 16, 32}) { @@ -547,16 +544,9 @@ public void bvOutOfRange() { bvmgr.makeBitvector(size, -(1L << (size - 1))); // forbitten values - try { - bvmgr.makeBitvector(size, 1L << size); - assert_().fail(); - } catch (IllegalArgumentException expected) { - } - try { - bvmgr.makeBitvector(size, -(1L << (size - 1)) - 1); - assert_().fail(); - } catch (IllegalArgumentException expected) { - } + assertThrows(IllegalArgumentException.class, () -> bvmgr.makeBitvector(size, 1L << size)); + assertThrows( + IllegalArgumentException.class, () -> bvmgr.makeBitvector(size, -(1L << (size - 1)) - 1)); } for (int size : new int[] {36, 40, 64, 65, 100, 128, 200, 250, 1000, 10000}) { @@ -572,17 +562,14 @@ public void bvOutOfRange() { bvmgr.makeBitvector(size, BigInteger.ONE.shiftLeft(size - 1).negate()); // forbitten values - try { - bvmgr.makeBitvector(size, BigInteger.ONE.shiftLeft(size)); - assert_().fail(); - } catch (IllegalArgumentException expected) { - } - try { - bvmgr.makeBitvector( - size, BigInteger.ONE.shiftLeft(size - 1).negate().subtract(BigInteger.ONE)); - assert_().fail(); - } catch (IllegalArgumentException expected) { - } + assertThrows( + IllegalArgumentException.class, + () -> bvmgr.makeBitvector(size, BigInteger.ONE.shiftLeft(size))); + assertThrows( + IllegalArgumentException.class, + () -> + bvmgr.makeBitvector( + size, BigInteger.ONE.shiftLeft(size - 1).negate().subtract(BigInteger.ONE))); } } diff --git a/src/org/sosy_lab/java_smt/test/FloatingPointFormulaManagerTest.java b/src/org/sosy_lab/java_smt/test/FloatingPointFormulaManagerTest.java index 33fc8e2acf..33585fb0dc 100644 --- a/src/org/sosy_lab/java_smt/test/FloatingPointFormulaManagerTest.java +++ b/src/org/sosy_lab/java_smt/test/FloatingPointFormulaManagerTest.java @@ -10,8 +10,8 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; -import static com.google.common.truth.Truth.assert_; import static com.google.common.truth.TruthJUnit.assume; +import static org.junit.Assert.assertThrows; import static org.sosy_lab.java_smt.test.ProverEnvironmentSubject.assertThat; import com.google.common.collect.ImmutableList; @@ -1024,11 +1024,9 @@ public void fpInterpolation() throws SolverException, InterruptedException { } } - @SuppressWarnings("CheckReturnValue") - @Test(expected = Exception.class) + @Test public void failOnInvalidString() { - fpmgr.makeNumber("a", singlePrecType); - assert_().fail(); + assertThrows(Exception.class, () -> fpmgr.makeNumber("a", singlePrecType)); } @Test diff --git a/src/org/sosy_lab/java_smt/test/InterpolatingProverTest.java b/src/org/sosy_lab/java_smt/test/InterpolatingProverTest.java index 8b4b26b1e5..b4d26d88cb 100644 --- a/src/org/sosy_lab/java_smt/test/InterpolatingProverTest.java +++ b/src/org/sosy_lab/java_smt/test/InterpolatingProverTest.java @@ -11,7 +11,6 @@ import static com.google.common.collect.Iterables.getLast; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; -import static com.google.common.truth.Truth.assert_; import static com.google.common.truth.TruthJUnit.assume; import static org.junit.Assert.assertThrows; import static org.sosy_lab.java_smt.test.ProverEnvironmentSubject.assertThat; @@ -362,8 +361,7 @@ public void sequentialInterpolationIsNotRepeatedIndividualInterpolation() } } - @Test(expected = IllegalArgumentException.class) - @SuppressWarnings("CheckReturnValue") + @Test public void sequentialInterpolationWithoutPartition() throws SolverException, InterruptedException { requireIntegers(); @@ -373,8 +371,8 @@ public void sequentialInterpolationWithoutPartition() assertThat(stack).isUnsatisfiable(); // empty list of partition - stack.getSeqInterpolants(ImmutableList.of()); - assert_().fail(); + assertThrows( + IllegalArgumentException.class, () -> stack.getSeqInterpolants(ImmutableList.of())); } @Test @@ -973,8 +971,7 @@ public void treeInterpolationMalFormed6() throws SolverException, Interrupte stack.getTreeInterpolants0(ImmutableList.of(TA, TA, TA), new int[] {0, 2, 0}); } - @Test(expected = IllegalArgumentException.class) - @SuppressWarnings("CheckReturnValue") + @Test public void treeInterpolationWithoutPartition() throws SolverException, InterruptedException { requireTreeItp(); @@ -984,8 +981,9 @@ public void treeInterpolationWithoutPartition() throws SolverException, Inte assertThat(stack).isUnsatisfiable(); // empty list of partition - stack.getTreeInterpolants(ImmutableList.of(), new int[] {}); - assert_().fail(); + assertThrows( + IllegalArgumentException.class, + () -> stack.getTreeInterpolants(ImmutableList.of(), new int[] {})); } @Test diff --git a/src/org/sosy_lab/java_smt/test/ModelTest.java b/src/org/sosy_lab/java_smt/test/ModelTest.java index 3fa91e29bc..bd9bd5d820 100644 --- a/src/org/sosy_lab/java_smt/test/ModelTest.java +++ b/src/org/sosy_lab/java_smt/test/ModelTest.java @@ -12,6 +12,7 @@ import static com.google.common.truth.Truth.assertWithMessage; import static com.google.common.truth.Truth.assert_; import static com.google.common.truth.TruthJUnit.assume; +import static org.junit.Assert.assertThrows; import static org.sosy_lab.java_smt.api.FormulaType.IntegerType; import static org.sosy_lab.java_smt.test.ProverEnvironmentSubject.assertThat; @@ -184,7 +185,7 @@ public void testGetRationals() throws SolverException, InterruptedException { /** Test that different names are no problem for Bools in the model. */ @Test public void testGetBooleans() throws SolverException, InterruptedException { - // Some names are specificly chosen to test the Boolector model + // Some names are specifically chosen to test the Boolector model for (String name : VARIABLE_NAMES) { testModelGetters(bmgr.makeVariable(name), bmgr.makeBoolean(true), true, name); } @@ -1207,12 +1208,12 @@ public void testGetArrays4() throws SolverException, InterruptedException { ImmutableList.of(BigInteger.valueOf(5))); } - @Test(expected = IllegalArgumentException.class) - @SuppressWarnings("CheckReturnValue") + @Test public void testGetArrays4invalid() throws SolverException, InterruptedException { requireParser(); requireArrays(); requireArrayModel(); + requireIntegers(); // create formula for "arr[5]==x && x==123" BooleanFormula f = @@ -1229,7 +1230,9 @@ public void testGetArrays4invalid() throws SolverException, InterruptedException assertThat(prover).isSatisfiable(); try (Model m = prover.getModel()) { - m.evaluate(amgr.makeArray("arr", ARRAY_TYPE_INT_INT)); + assertThrows( + IllegalArgumentException.class, + () -> m.evaluate(amgr.makeArray("arr", ARRAY_TYPE_INT_INT))); } } } @@ -2306,22 +2309,19 @@ public void modelAfterSolverCloseTest() throws SolverException, InterruptedExcep } } - @SuppressWarnings("resource") - @Test(expected = IllegalStateException.class) + @Test public void testGenerateModelsOption() throws SolverException, InterruptedException { try (ProverEnvironment prover = context.newProverEnvironment()) { // no option assertThat(prover).isSatisfiable(); - prover.getModel(); - assert_().fail(); + assertThrows(IllegalStateException.class, () -> prover.getModel()); } } - @Test(expected = IllegalStateException.class) + @Test public void testGenerateModelsOption2() throws SolverException, InterruptedException { try (ProverEnvironment prover = context.newProverEnvironment()) { // no option assertThat(prover).isSatisfiable(); - prover.getModelAssignments(); - assert_().fail(); + assertThrows(IllegalStateException.class, () -> prover.getModelAssignments()); } } diff --git a/src/org/sosy_lab/java_smt/test/RationalFormulaManagerTest.java b/src/org/sosy_lab/java_smt/test/RationalFormulaManagerTest.java index 1515133f88..df75ec0fd2 100644 --- a/src/org/sosy_lab/java_smt/test/RationalFormulaManagerTest.java +++ b/src/org/sosy_lab/java_smt/test/RationalFormulaManagerTest.java @@ -9,8 +9,8 @@ package org.sosy_lab.java_smt.test; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth.assert_; import static com.google.common.truth.TruthJUnit.assume; +import static org.junit.Assert.assertThrows; import com.google.common.collect.Iterables; import java.util.HashSet; @@ -139,10 +139,8 @@ protected Boolean visitDefault(Formula pF) { } } - @SuppressWarnings("CheckReturnValue") - @Test(expected = Exception.class) + @Test public void failOnInvalidString() { - rmgr.makeNumber("a"); - assert_().fail(); + assertThrows(Exception.class, () -> rmgr.makeNumber("a")); } } diff --git a/src/org/sosy_lab/java_smt/test/SolverTacticsTest.java b/src/org/sosy_lab/java_smt/test/SolverTacticsTest.java index db5b9841ae..2783a535a7 100644 --- a/src/org/sosy_lab/java_smt/test/SolverTacticsTest.java +++ b/src/org/sosy_lab/java_smt/test/SolverTacticsTest.java @@ -9,7 +9,7 @@ package org.sosy_lab.java_smt.test; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth.assert_; +import static org.junit.Assert.assertThrows; import static org.sosy_lab.java_smt.api.FormulaType.BooleanType; import static org.sosy_lab.java_smt.api.FormulaType.IntegerType; @@ -199,7 +199,7 @@ public void ufEliminationNestedUfsTest() throws SolverException, InterruptedExce } @Test - public void ufEliminationNesteQuantifierTest() throws InterruptedException { + public void ufEliminationNesteQuantifierTest() { requireIntegers(); requireQuantifiers(); // f := exists v1,v2v,v3,v4 : uf(v1, v3) == uf(v2, v4) @@ -216,11 +216,7 @@ public void ufEliminationNesteQuantifierTest() throws InterruptedException { qmgr.exists( ImmutableList.of(variable1, variable2, variable3, variable4), bmgr.equivalence(f1, f2)); - try { - mgr.applyTactic(f, Tactic.ACKERMANNIZATION); - assert_().fail(); - } catch (IllegalArgumentException expected) { - } + assertThrows(IllegalArgumentException.class, () -> mgr.applyTactic(f, Tactic.ACKERMANNIZATION)); } private static class CNFChecker implements BooleanFormulaVisitor { diff --git a/src/org/sosy_lab/java_smt/test/UfEliminationTest.java b/src/org/sosy_lab/java_smt/test/UfEliminationTest.java index c2e40f1d13..5f3bbe2e01 100644 --- a/src/org/sosy_lab/java_smt/test/UfEliminationTest.java +++ b/src/org/sosy_lab/java_smt/test/UfEliminationTest.java @@ -8,8 +8,8 @@ package org.sosy_lab.java_smt.test; -import static com.google.common.truth.Truth.assert_; import static com.google.common.truth.TruthJUnit.assume; +import static org.junit.Assert.assertThrows; import static org.sosy_lab.java_smt.api.FormulaType.BooleanType; import static org.sosy_lab.java_smt.api.FormulaType.IntegerType; @@ -238,11 +238,7 @@ public void quantifierTest() { qmgr.exists( ImmutableList.of(variable1, variable2, variable3, variable4), bmgr.equivalence(f1, f2)); - try { - ackermannization.eliminateUfs(f); - assert_().fail(); - } catch (IllegalArgumentException expected) { - } + assertThrows(IllegalArgumentException.class, () -> ackermannization.eliminateUfs(f)); } @Test