def test_unary_expr(): pe1 = ast.primary_expr(True) op1 = ast.operand(pe1) ue1 = ast.unary_expr(ast.optoken.op_not, op1) assert(ue1.operator == ast.optoken.op_not) assert(ue1.operand == op1) id2 = ast.identifier('ident') pe2 = ast.primary_expr(id2) op2 = ast.operand(pe2) ue2 = ast.unary_expr(ast.optoken.op_negative, op2) assert(ue2.operator == ast.optoken.op_negative) assert(ue2.operand == op2)
def test_operation(): pe1 = ast.primary_expr(True) op1 = ast.operand(pe1) op2 = ast.operation(ast.optoken.op_plus, op1) assert(op2.operator == ast.optoken.op_plus) assert(op2.operand == op1) id2 = ast.identifier('ident') pe2 = ast.primary_expr(id2) op3 = ast.operand(pe2) op4 = ast.unary_expr(ast.optoken.op_minus, op3) assert(op4.operator == ast.optoken.op_minus) assert(op4.operand == op3)
def __init__(self,a): self.a = a self.value = ast.unary_expr(ast.optoken.op_negative,oper(a.value))