def test_construction(self): """Build an eager model out of a dictionary""" x, y = FreshSymbol(), FreshSymbol() d = {x: TRUE(), y: FALSE()} model = EagerModel(assignment=d) self.assertEqual(model.get_value(x), TRUE()) self.assertEqual(model.get_value(y), FALSE()) self.assertEqual(model.get_value(And(x, y)), FALSE())
def test_construction(self): """Build an eager model out of a dictionary""" x, y = FreshSymbol(), FreshSymbol() d = {x: TRUE(), y: FALSE()} model = EagerModel(assignment=d) self.assertEqual(model.get_value(x), TRUE()) self.assertEqual(model.get_value(y), FALSE()) self.assertEqual(model.get_value(And(x,y)), FALSE())
def test_result_is_const(self): """The result of get_value is a constant""" x, y = FreshSymbol(), FreshSymbol() d = {x: TRUE()} model = EagerModel(assignment=d) with self.assertRaises(PysmtTypeError): model.get_value(And(x, y), model_completion=False) d2 = {x: TRUE(), y: x} model = EagerModel(assignment=d2) with self.assertRaises(PysmtTypeError): model.get_value(And(x, y))
def test_result_is_const(self): """The result of get_value is a constant""" x, y = FreshSymbol(), FreshSymbol() d = {x:TRUE()} model = EagerModel(assignment=d) with self.assertRaises(TypeError): model.get_value(And(x,y), model_completion=False) d2 = {x:TRUE(), y:x} model = EagerModel(assignment=d2) with self.assertRaises(TypeError): model.get_value(And(x,y))
def test_env_default_arguments(self): """Test use global env""" x = FreshSymbol() d = {x: TRUE()} model = EagerModel(d) self.assertEqual(model.get_value(x), TRUE())
def test_complete_model(self): """Given a partial assignment, we can make a total model.""" x, y = FreshSymbol(), FreshSymbol() r = FreshSymbol(REAL) p = FreshSymbol(INT) d = {x: TRUE()} model = EagerModel(assignment=d) self.assertEqual(model.get_value(x), TRUE()) self.assertEqual(model.get_value(Or(x, y)), TRUE()) self.assertTrue(model.get_value(p).is_constant(INT)) self.assertTrue(model.get_value(r).is_constant(REAL)) self.assertEqual(model.get_value(x, model_completion=False), TRUE()) with self.assertRaises(PysmtTypeError): model.get_value(And(x, y), model_completion=False) with self.assertRaises(PysmtTypeError): model.get_value(p, model_completion=False) with self.assertRaises(PysmtTypeError): model.get_value(r, model_completion=False)
def test_complete_model(self): """Given a partial assignment, we can make a total model.""" x, y = FreshSymbol(), FreshSymbol() r = FreshSymbol(REAL) p = FreshSymbol(INT) d = {x:TRUE()} model = EagerModel(assignment=d) self.assertEqual(model.get_value(x), TRUE()) self.assertEqual(model.get_value(Or(x,y)), TRUE()) self.assertTrue(model.get_value(p).is_constant(INT)) self.assertTrue(model.get_value(r).is_constant(REAL)) self.assertEqual(model.get_value(x, model_completion=False), TRUE()) with self.assertRaises(TypeError): model.get_value(And(x,y), model_completion=False) with self.assertRaises(TypeError): model.get_value(p, model_completion=False) with self.assertRaises(TypeError): model.get_value(r, model_completion=False)