def testParsePostfixExpression(self): testCases = [ '(!a)++', '(a+b)++', 'd--', '1--', ] for testCase in testCases: parser = self.makeStringParser(testCase) result = parser.parse_unary_expression() self.assertIsNode('PostfixCountOperation', result)
def testParseUnaryExpression(self): testCases = { 'parse-not': ('!a', 'UnaryOperation'), 'parse-negate': ('-a', 'UnaryOperation'), 'parse-positive': ('+a', 'UnaryOperation'), 'parse-bitnot': ('~a', 'UnaryOperation'), 'parse-delete': ('delete a', 'DeleteOperation'), 'parse-void': ('void a', 'VoidOperation'), 'parse-typeof': ('typeof a', 'TypeofOperation'), 'parse-prefix-count-plus': ('++a', 'PrefixCountOperation'), 'parse-prefix-count-minus': ('--a', 'PrefixCountOperation'), } for test_name, (string, expected) in testCases.iteritems(): parser = self.makeStringParser(string) result = parser.parse_unary_expression() fmt_args = (test_name, expected, result.__class__.__name__) msg = '%s did not parse an %s; got %s' % fmt_args self.assertIsNode(expected, result, msg=msg)