def testPrefixMinusLowPrecedence(self): query = "-5 * 5" expected = expression.Product( expression.Literal(-1), expression.Product(expression.Literal(5), expression.Literal(5))) self.assertQueryMatches(query, expected)
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)
def testPrefixMinus(self): query = "-(5 + 5)" expected = expression.Product( expression.Literal(-1), expression.Sum(expression.Literal(5), expression.Literal(5))) self.assertQueryMatches(query, expected)
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)
def NegateValue(*args, **kwargs): return expression.Product( expression.Literal(-1), *args, **kwargs)