Exemplo n.º 1
0
    def test_equal(self):
        from boolean.boolean import DualBase
        a, b, c = Symbol('a'), Symbol('b'), Symbol('c')
        t1 = DualBase(a, b)
        t1_2 = DualBase(b, a)

        t2 = DualBase(a, b, c)
        t2_2 = DualBase(b, c, a)

        # Test __eq__.
        self.assertTrue(t1 == t1)
        self.assertTrue(t1_2 == t1)
        self.assertTrue(t2_2 == t2)
        self.assertFalse(t1 == t2)
        self.assertFalse(t1 == 1)
        self.assertFalse(t1 is True)
        self.assertFalse(t1 is None)

        # Test __ne__.
        self.assertFalse(t1 != t1)
        self.assertFalse(t1_2 != t1)
        self.assertFalse(t2_2 != t2)
        self.assertTrue(t1 != t2)
        self.assertTrue(t1 != 1)
        self.assertTrue(t1 is not True)
        self.assertTrue(t1 is not None)
Exemplo n.º 2
0
    def test_isliteral(self):
        from boolean.boolean import DualBase
        a, b, c = Symbol('a'), Symbol('b'), Symbol('c')
        t1 = DualBase(a, b)
        t2 = DualBase(a, b, c)

        self.assertFalse(t1.isliteral)
        self.assertFalse(t2.isliteral)
Exemplo n.º 3
0
    def test_init(self):
        from boolean.boolean import DualBase
        a, b, c = Symbol('a'), Symbol('b'), Symbol('c')
        t1 = DualBase(a, b)
        t2 = DualBase(a, b, c)
        t3 = DualBase(a, a)
        t4 = DualBase(a, b, c)

        self.assertRaises(TypeError, DualBase)
        for term in (t1, t2, t3, t4):
            self.assertTrue(isinstance(term, DualBase))
Exemplo n.º 4
0
    def test_literals(self):
        from boolean.boolean import DualBase
        a, b, c = Symbol('a'), Symbol('b'), Symbol('c')
        t1 = DualBase(a, b)
        t2 = DualBase(a, b, c)
        t3 = DualBase(a, a)
        t4 = DualBase(a, b, c)

        for term in (t1, t2, t3, t4):
            self.assertTrue(a in term.literals)
        for term in (t1, t2, t4):
            self.assertTrue(b in term.literals)
        for term in (t2, t4):
            self.assertTrue(c in term.literals)