class prop_logicTest(InvenioTestCase): """Testing basic propositional logic functionality""" P = Expr('P') def test_pl_true_P_true(self): """logicutils - True thing is evaluated as such""" self.assertEqual(pl_true(self.P, {self.P: True}), True) def test_pl_true_P_false(self): """logicutils - False thing is evaluated as such""" self.assertEqual(pl_true(self.P, {self.P: False}), False)
def test_ANDed_pair(self): """logicutils - ANDed pair should be in CNF""" self.assertEqual(to_cnf(expr('a & b')), Expr('&', 'a', 'b'))
def test_ORed_pair(self): """logicutils - ORed pair should be in CNF""" self.assertEqual(to_cnf(expr('a | b')), Expr('|', 'a', 'b'))
def test_singleton(self): """logicutils - singletons are already in CNF""" self.assertEqual(to_cnf(expr('a')), Expr('a'))
def test_deep_expr(self): """logicutils - create deep Expr with expr()""" self.assertEqual( expr('a | b | c | d | e'), Expr('|', Expr('|', Expr('|', Expr('|', 'a', 'b'), 'c'), 'd'), 'e'))
def test_trivial_expr(self): """logicutils - create trivial Expr with expr()""" self.assertEqual(expr('a | b'), Expr('|', 'a', 'b'))