def test_evaluation_works(self): random.seed("satisfaction 1") values = set() for depth in xrange(10): for _ in xrange(10): formula = random_formula(depth) a = random_assignment(formula) x = formula.evaluate(a) values.add(x) self.assertIn(x, (True, False)) symbol = random.choice(list(a)) del a[symbol] self.assertRaises(UnassignedSymbol, formula.evaluate, a) if depth == 0: break self.assertEqual(len(values), 2)
def brute_t3st_transformation(self, transformer, checker=None, implies=False): for depth in xrange(4): for _ in xrange(10): formula = random_formula(depth) transformed = transformer(formula) if checker is not None: self.assertTrue(checker(transformed)) for _ in xrange(1000): a = random_assignment(transformed) x = formula.evaluate(a) y = transformed.evaluate(a) if implies: self.assertTrue(not y or x) else: self.assertEqual(x, y) if depth == 0: break