def test_msat_converter_on_msat_error(self): import mathsat import _mathsat from pysmt.solvers.msat import MathSAT5Solver, MSatConverter env = get_env() msat = MathSAT5Solver(env, logic=QF_UFLIRA) new_converter = MSatConverter(env, msat.msat_env) def walk_plus(formula, args): res = mathsat.MSAT_MAKE_ERROR_TERM() return res # Replace the function used to compute the Plus() # with one that returns a msat_error new_converter.set_function(walk_plus, op.PLUS) r, s = FreshSymbol(REAL), FreshSymbol(REAL) f1 = GT(r, s) f2 = Plus(r, s) t1 = new_converter.convert(f1) self.assertFalse(mathsat.MSAT_ERROR_TERM(t1)) with self.assertRaises(InternalSolverError): new_converter.convert(f2)
def convert(self, formula): """Convert a PySMT formula into a MathSat Term. This function might throw a InternalSolverError exception if an error during conversion occurs. """ res = self.walk(formula) if mathsat.MSAT_ERROR_TERM(res): msat_msg = mathsat.msat_last_error_message(self.msat_env) raise InternalSolverError(msat_msg) return res
def test_msat_converter_on_msat_error(self): import mathsat from pysmt.solvers.msat import MathSAT5Solver, MSatConverter env = get_env() msat = MathSAT5Solver(env, logic=QF_UFLIRA) class NewConverter(MSatConverter): def walk_plus(self, formula, args, **kwargs): res = mathsat.MSAT_MAKE_ERROR_TERM() return res new_converter = NewConverter(env, msat.msat_env) r, s = FreshSymbol(REAL), FreshSymbol(REAL) f1 = GT(r, s) f2 = Plus(r, s) t1 = new_converter.convert(f1) self.assertFalse(mathsat.MSAT_ERROR_TERM(t1)) with self.assertRaises(InternalSolverError): new_converter.convert(f2)