Пример #1
0
    def testPrefixMinusLowPrecedence(self):
        query = "-5 * 5"
        expected = expression.Product(
            expression.Literal(-1),
            expression.Product(expression.Literal(5), expression.Literal(5)))

        self.assertQueryMatches(query, expected)
Пример #2
0
    def testParens(self):
        query = "(3 + 2) * 5"
        expected = expression.Product(
            expression.Sum(expression.Literal(3), expression.Literal(2)),
            expression.Literal(5))

        self.assertQueryMatches(query, expected)
Пример #3
0
    def testPrefixMinus(self):
        query = "-(5 + 5)"
        expected = expression.Product(
            expression.Literal(-1),
            expression.Sum(expression.Literal(5), expression.Literal(5)))

        self.assertQueryMatches(query, expected)
Пример #4
0
 def testPrecedence(self):
     query = "5 == 1 * 5 and Process/name is 'init'"
     expected = expression.Intersection(
         expression.Equivalence(
             expression.Literal(5),
             expression.Product(expression.Literal(1),
                                expression.Literal(5))),
         expression.Equivalence(expression.Binding("Process/name"),
                                expression.Literal("init")))
     self.assertQueryMatches(query, expected)
Пример #5
0
def NegateValue(*args, **kwargs):
    return expression.Product(
        expression.Literal(-1),
        *args,
        **kwargs)