Exemplo n.º 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']
Exemplo n.º 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']
Exemplo n.º 3
0
 def test_parens(self):
     expr = 'not (x and y)'
     postfix = list(expression.build_postfix_expression(expr))
     assert postfix == ['x', 'y', 'and', 'not']
Exemplo n.º 4
0
 def test_precedence(self):
     expr = 'not x and y'
     postfix = list(expression.build_postfix_expression(expr))
     assert postfix == ['x', 'not', 'y', 'and']
Exemplo n.º 5
0
 def test_payee_at(self):
     expr = '@x'
     postfix = list(expression.build_postfix_expression(expr))
     assert postfix == ['x', '@']
Exemplo n.º 6
0
 def test_unary_precedence(self):
     expr = 'not payee x'
     postfix = list(expression.build_postfix_expression(expr))
     assert postfix == ['x', 'payee', 'not']
Exemplo n.º 7
0
 def test_payee(self):
     expr = 'payee x'
     postfix = list(expression.build_postfix_expression(expr))
     assert postfix == ['x', 'payee']
Exemplo n.º 8
0
 def test_not(self):
     expr = 'not x'
     postfix = list(expression.build_postfix_expression(expr))
     assert postfix == ['x', 'not']
Exemplo n.º 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']