Esempio n. 1
0
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))
Esempio n. 2
0
def test_parse_negation():
    expected = nodes.neg(nodes.ref("x"))
    _assert_expression_parse(expected, "-x")
Esempio n. 3
0
def unary_operation_has_child_names_resolved():
    _assert_children_resolved(
        lambda ref: nodes.neg(ref),
    )
Esempio n. 4
0
 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__"), [])
     )