Пример #1
0
    def test_and(self):
        expr = 'x and y'
        postfix = list(expression.build_postfix_expression(expr))
        assert postfix == ['x', 'y', 'and']

        expr = 'x and y and z'
        postfix = list(expression.build_postfix_expression(expr))
        assert postfix == ['x', 'y', 'and', 'z', 'and']
Пример #2
0
    def test_implicit_or(self):
        expr = 'x y'
        postfix = list(expression.build_postfix_expression(expr))
        assert postfix == ['x', 'y', 'or']

        expr = 'x y z'
        postfix = list(expression.build_postfix_expression(expr))
        assert postfix == ['x', 'y', 'or', 'z', 'or']

        expr = '(x y) z'
        postfix = list(expression.build_postfix_expression(expr))
        assert postfix == ['x', 'y', 'or', 'z', 'or']

        expr = 'x (y or z)'
        postfix = list(expression.build_postfix_expression(expr))
        assert postfix == ['x', 'y', 'z', 'or', 'or']
Пример #3
0
 def test_parens(self):
     expr = 'not (x and y)'
     postfix = list(expression.build_postfix_expression(expr))
     assert postfix == ['x', 'y', 'and', 'not']
Пример #4
0
 def test_precedence(self):
     expr = 'not x and y'
     postfix = list(expression.build_postfix_expression(expr))
     assert postfix == ['x', 'not', 'y', 'and']
Пример #5
0
 def test_payee_at(self):
     expr = '@x'
     postfix = list(expression.build_postfix_expression(expr))
     assert postfix == ['x', '@']
Пример #6
0
 def test_unary_precedence(self):
     expr = 'not payee x'
     postfix = list(expression.build_postfix_expression(expr))
     assert postfix == ['x', 'payee', 'not']
Пример #7
0
 def test_payee(self):
     expr = 'payee x'
     postfix = list(expression.build_postfix_expression(expr))
     assert postfix == ['x', 'payee']
Пример #8
0
 def test_not(self):
     expr = 'not x'
     postfix = list(expression.build_postfix_expression(expr))
     assert postfix == ['x', 'not']
Пример #9
0
 def test_or(self):
     expr = 'x or y or z'
     postfix = list(expression.build_postfix_expression(expr))
     assert postfix == ['x', 'y', 'or', 'z', 'or']