|
27 | 27 | import org.sosy_lab.java_smt.api.IntegerFormulaManager;
|
28 | 28 | import org.sosy_lab.java_smt.api.InterpolatingProverEnvironment;
|
29 | 29 | import org.sosy_lab.java_smt.api.SolverContext;
|
| 30 | +import org.sosy_lab.java_smt.api.SolverContext.ProverOptions; |
30 | 31 | import org.sosy_lab.java_smt.api.SolverException;
|
31 | 32 | import org.sosy_lab.java_smt.solvers.opensmt.Logics;
|
32 | 33 |
|
@@ -284,4 +285,55 @@ public <T> void nonlocalInterpolationTest() throws InterruptedException, Executi
|
284 | 285 | assert task3.get() == null;
|
285 | 286 | }
|
286 | 287 | }
|
| 288 | + |
| 289 | + @SuppressWarnings("resource") |
| 290 | + @Test |
| 291 | + public void wrongContextTest() throws InterruptedException, SolverException { |
| 292 | + assume() |
| 293 | + .that(solverToUse()) |
| 294 | + .isNoneOf( |
| 295 | + Solvers.OPENSMT, |
| 296 | + Solvers.MATHSAT5, |
| 297 | + Solvers.SMTINTERPOL, |
| 298 | + Solvers.Z3, |
| 299 | + Solvers.PRINCESS, |
| 300 | + Solvers.BOOLECTOR); |
| 301 | + |
| 302 | + // FIXME: This test tries to use a formula that was created in a different context. We expect |
| 303 | + // this test to fail for most solvers, but there should be a unique error message. |
| 304 | + // Right now we get: |
| 305 | + // OpenSMT claims the formula is satisfiable: |
| 306 | + // expected to be : unsatisfiable |
| 307 | + // but was : org.sosy_lab.java_smt.solvers.opensmt.OpenSmtTheoremProver@10d59286 |
| 308 | + // which is : satisfiable |
| 309 | + // which has model: |
| 310 | + // MathSAT5 thows an IllegalStateExpression: |
| 311 | + // msat_solve returned "unknown": polarity information is meaningful only for terms of |
| 312 | + // type Bool |
| 313 | + // SMTInterpol thows an de.uni_freiburg.informatik.ultimate.logic.SMTLIBException: |
| 314 | + // Asserted terms created with incompatible theory |
| 315 | + // Z3 throws an com.microsoft.z3.Z3Exception: |
| 316 | + // invalid argument |
| 317 | + // Princess throws an java.util.NoSuchElementException: |
| 318 | + // key not found: i@15 |
| 319 | + // Boolector crashes with a segfault: |
| 320 | + // boolector_assert: argument 'exp' belongs to different Boolector instance |
| 321 | + |
| 322 | + HardIntegerFormulaGenerator gen = new HardIntegerFormulaGenerator(imgr, bmgr); |
| 323 | + |
| 324 | + // Boolector does not support integer, so we have to use two different versions for this test. |
| 325 | + BooleanFormula formula = |
| 326 | + solverToUse() == Solvers.BOOLECTOR ? bmgr.makeFalse() : gen.generate(8); |
| 327 | + |
| 328 | + try (SolverContext newContext = factory.generateContext()) { |
| 329 | + try (BasicProverEnvironment<?> prover = |
| 330 | + newContext.newProverEnvironment(ProverOptions.GENERATE_MODELS)) { |
| 331 | + // Trying to add a formula from our global context to the newly created solver context. |
| 332 | + prover.push(formula); |
| 333 | + assertThat(prover).isUnsatisfiable(); |
| 334 | + } |
| 335 | + } catch (InvalidConfigurationException e) { |
| 336 | + throw new RuntimeException(e); |
| 337 | + } |
| 338 | + } |
287 | 339 | }
|
0 commit comments