コード例 #1
0
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)
コード例 #2
0
 def test_ANDed_pair(self):
     """logicutils - ANDed pair should be in CNF"""
     self.assertEqual(to_cnf(expr('a & b')), Expr('&', 'a', 'b'))
コード例 #3
0
 def test_ORed_pair(self):
     """logicutils - ORed pair should be in CNF"""
     self.assertEqual(to_cnf(expr('a | b')), Expr('|', 'a', 'b'))
コード例 #4
0
 def test_singleton(self):
     """logicutils - singletons are already in CNF"""
     self.assertEqual(to_cnf(expr('a')), Expr('a'))
コード例 #5
0
 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'))
コード例 #6
0
 def test_trivial_expr(self):
     """logicutils - create trivial Expr with expr()"""
     self.assertEqual(expr('a | b'), Expr('|', 'a', 'b'))