Ejemplo n.º 1
0
    def test_creating_AND_OR_AND_NOT(self):
        fifth = Tree("hello AND world OR hello AND NOT world") # TODO::test optimizations

        b = Tree()
        b.operator = Operation.OR

        l_1 = Tree()
        l_1.operator = Operation.AND
        l_1_l = Tree("hello")
        l_1_r = Tree("world")
        l_1.left = l_1_l
        l_1.right = l_1_r

        r_1 = Tree()
        r_1.operator = Operation.AND
        r_1_r = Tree()
        r_1_r.operator = Operation.NOT
        r_1_r_r = Tree("world")
        r_1_r.right = r_1_r_r
        r_1_l = Tree("hello")
        r_1.right = r_1_r
        r_1.left = r_1_l

        b.right = r_1
        b.left = l_1

        self.assertTrue(self.checkEquality(fifth, b))
Ejemplo n.º 2
0
 def test_creating_paran3(self):
     third = Tree("earth AND (hello OR world)")
     b = Tree()
     b.operator = Operation.AND
     br, bl = Tree("hello OR world"), Tree("earth")
     b.left = bl
     b.right = br
     self.assertTrue(self.checkEquality(third, b))
Ejemplo n.º 3
0
 def test_creating_paran2(self):
     second = Tree("(hello OR world) AND earth")
     b = Tree()
     b.operator = Operation.AND
     bl, br = Tree("hello OR world"), Tree("earth")
     b.left = bl
     b.right = br
     self.assertTrue(self.checkEquality(second, b))
Ejemplo n.º 4
0
 def test_creating_paran8(self):
     tr = Tree("(computer AND terminal) OR (soybean AND crush)")
     b = Tree()
     b.operator = Operation.OR
     br = Tree("soybean AND crush")
     bl = Tree("computer AND terminal")
     b.right = br
     b.left = bl
     self.assertTrue(self.checkEquality(tr, b))
Ejemplo n.º 5
0
 def test_creatingOR(self):
     second = Tree("hello OR world")
     b = Tree()
     b.operator = Operation.OR
     l = Tree("hello")
     r = Tree("world")
     b.right = r
     b.left = l
     self.assertTrue(self.checkEquality(second, b))
     logging.debug(second)
Ejemplo n.º 6
0
 def test_creatingAND(self):
     first = Tree("hello AND world")
     b = Tree()
     b.operator = Operation.AND
     l = Tree("hello")
     r = Tree("world")
     b.right = r
     b.left = l
     self.assertTrue(self.checkEquality(first, b))
     logging.debug(first)
Ejemplo n.º 7
0
    def test_creating_paran6(self):
        tr = Tree("earth AND NOT (hello OR world) OR (mars AND jupiter)")

        b = Tree()
        b.operator = Operation.OR
        br = Tree("(mars AND jupiter)")
        bl = Tree("earth AND NOT (hello OR world)")
        
        b.left = bl
        b.right = br

        self.assertTrue(self.checkEquality(tr, b))
Ejemplo n.º 8
0
    def test_creating_paran4(self):
        tr = Tree("earth AND NOT (hello OR world)")
        b = Tree()
        b.operator = Operation.AND
        bl = Tree("earth")
        br = Tree()
        br.operator = Operation.NOT
        brr = Tree("hello OR world")
        br.right = brr
        
        b.left = bl
        b.right = br

        self.assertTrue(self.checkEquality(tr, b))
Ejemplo n.º 9
0
    def test_creatingNOT_OR(self):
        fourth = Tree("NOT hello OR world")

        b = Tree()
        b.operator = Operation.OR
        l = Tree("hello")
        l_base = Tree()
        l_base.operator = Operation.NOT
        l_base.right = l
        r = Tree("world")
        b.right = r
        b.left = l_base

        self.assertTrue(self.checkEquality(fourth, b))
Ejemplo n.º 10
0
 def test_creatingAND_NOT(self):
     third = Tree("hello AND NOT world")
     b = Tree()
     b.operator = Operation.AND
     l = Tree("hello")
     r = Tree("world")
     r_base = Tree()
     r_base.operator = Operation.NOT
     r_base.right = r
     b.right = r_base
     b.left = l
     self.assertTrue(self.checkEquality(third, b))
     
     logging.debug(third)