Example #1
0
 def test_expression_parse_implicit_mixed_2(self):
     e = Expression('b1 or b2 and b3 or b4')
     self.assertEqual(
         e,
         Expression(
             Or(Variable('b1'), And(Variable('b2'), Variable('b3')),
                Variable('b4'))))
Example #2
0
 def test_expression_parse_multiple_parenthesis_or(self):
     e = Expression('b1 or (b2 or b3) or b4')
     self.assertEqual(
         e,
         Expression(
             Or(Variable('b1'), Variable('b2'), Variable('b3'),
                Variable('b4'))))
Example #3
0
 def test_expression_parse_parentheses_mixed_1(self):
     e = Expression('(b1 and b2) or (b3 and b4)')
     self.assertEqual(
         e,
         Expression(
             Or(And(Variable('b1'), Variable('b2')),
                And(Variable('b3'), Variable('b4')))))
Example #4
0
 def test_expression_parse_with_square_mixed_groups(self):
     e = Expression('[(a or b) or (c or d)] or [e or (f and g and h)]')
     self.assertEqual(
         e,
         Expression(
             Or(Variable('a'), Variable('b'), Variable('c'), Variable('d'),
                Variable('e'),
                And(Variable('f'), Variable('g'), Variable('h')))))
Example #5
0
 def test_expression_iter_variables(self):
     e = Expression(
         Or(And(Variable('b1'), Variable('b2')),
            And(Variable('b3'), Variable('b4'))))
     self.assertEqual(
         list(e.variables),
         [Variable('b1'),
          Variable('b2'),
          Variable('b3'),
          Variable('b4')])
Example #6
0
 def test_expression_parse_name_starting_with_and(self):
     e = Expression('b1 or anderson')
     self.assertEqual(e, Expression(Or(Variable('b1'),
                                       Variable('anderson'))))
Example #7
0
 def test_expression_parse_uppercase_operators(self):
     e = Expression('(b1 AND b2) OR b3')
     self.assertEqual(
         e,
         Expression(Or(Variable('b3'), And(Variable('b1'),
                                           Variable('b2')))))
Example #8
0
 def test_expression_parse_or(self):
     e = Expression('b1 or b2')
     self.assertEqual(e, Expression(Or(Variable('b1'), Variable('b2'))))
Example #9
0
 def test_expression_root(self):
     e = Expression(Or(Variable('b1'), Variable('b2')))
     root = e.root
     self.assertIsInstance(e.root, Or)
Example #10
0
 def test_length_of_or(self):
     term = Or(Variable('b1'), And(Variable('b2'), Variable('b3')))
     self.assertEqual(len(term), 2)