def can_infer_type_of_negation_operation(): type_bindings = {"x": types.int_type} negation = nodes.neg(nodes.ref("x")) assert_equal(types.int_type, infer(negation, type_bindings=type_bindings))
def test_parse_negation(): expected = nodes.neg(nodes.ref("x")) _assert_expression_parse(expected, "-x")
def unary_operation_has_child_names_resolved(): _assert_children_resolved( lambda ref: nodes.neg(ref), )
def test_transform_unary_operation_is_converted_to_call_on_class(self): _assert_transform( nodes.neg(nodes.ref("x")), cc.call(cc.attr(cc.ref("x"), "__neg__"), []) )