*/
void Solver::pop(uint32_t nscopes) const
{
- // CHECK: incremental enabled?
- // CHECK: nscopes <= d_smtEngine->d_userLevels.size()
+ CVC4_API_SOLVER_TRY_CATCH_BEGIN;
+ CVC4_API_CHECK(d_smtEngine->getOption("incremental").toString() == "true")
+ << "Cannot pop when not solving incrementally (use --incremental)";
+ CVC4_API_CHECK(nscopes <= d_smtEngine->getNumUserLevels())
+ << "Cannot pop beyond first pushed context";
+
for (uint32_t n = 0; n < nscopes; ++n)
{
d_smtEngine->pop();
}
+ CVC4_API_SOLVER_TRY_CATCH_END;
}
void Solver::printModel(std::ostream& out) const
*/
void Solver::push(uint32_t nscopes) const
{
- // CHECK: incremental enabled?
+ CVC4_API_SOLVER_TRY_CATCH_BEGIN;
+ CVC4_API_CHECK(d_smtEngine->getOption("incremental").toString() == "true")
+ << "Cannot push when not solving incrementally (use --incremental)";
+
for (uint32_t n = 0; n < nscopes; ++n)
{
d_smtEngine->push();
}
+ CVC4_API_SOLVER_TRY_CATCH_END;
}
/**
void testDefineFunRec();
void testDefineFunsRec();
+ void testPush1();
+ void testPush2();
+ void testPop1();
+ void testPop2();
+ void testPop3();
+
void testSetInfo();
void testSetLogic();
void testSetOption();
CVC4ApiException&);
}
+void SolverBlack::testPush1()
+{
+ d_solver->setOption("incremental", "true");
+ TS_ASSERT_THROWS_NOTHING(d_solver->push(1));
+ TS_ASSERT_THROWS(d_solver->setOption("incremental", "false"),
+ CVC4ApiException&);
+ TS_ASSERT_THROWS(d_solver->setOption("incremental", "true"),
+ CVC4ApiException&);
+}
+
+void SolverBlack::testPush2()
+{
+ d_solver->setOption("incremental", "false");
+ TS_ASSERT_THROWS(d_solver->push(1), CVC4ApiException&);
+}
+
+void SolverBlack::testPop1()
+{
+ d_solver->setOption("incremental", "false");
+ TS_ASSERT_THROWS(d_solver->pop(1), CVC4ApiException&);
+}
+
+void SolverBlack::testPop2()
+{
+ d_solver->setOption("incremental", "true");
+ TS_ASSERT_THROWS(d_solver->pop(1), CVC4ApiException&);
+}
+
+void SolverBlack::testPop3()
+{
+ d_solver->setOption("incremental", "true");
+ TS_ASSERT_THROWS_NOTHING(d_solver->push(1));
+ TS_ASSERT_THROWS_NOTHING(d_solver->pop(1));
+ TS_ASSERT_THROWS(d_solver->pop(1), CVC4ApiException&);
+}
+
void SolverBlack::testSetInfo()
{
TS_ASSERT_THROWS(d_solver->setInfo("cvc4-lagic", "QF_BV"), CVC4ApiException&);