MCPcopy Index your code
hub / github.com/python/mypy / assert_emit_binary_op

Method assert_emit_binary_op

mypyc/test/test_emitfunc.py:1023–1051  ·  view source on GitHub ↗
(
        self, op: str, dest: Value, left: Value, right: Value, expected: str
    )

Source from the content-addressed store, hash-verified

1021 assert visitor.op_index == 0
1022
1023 def assert_emit_binary_op(
1024 self, op: str, dest: Value, left: Value, right: Value, expected: str
1025 ) -> None:
1026 if op in binary_ops:
1027 ops = binary_ops[op]
1028 for desc in ops:
1029 if is_subtype(left.type, desc.arg_types[0]) and is_subtype(
1030 right.type, desc.arg_types[1]
1031 ):
1032 args = [left, right]
1033 if desc.ordering is not None:
1034 args = [args[i] for i in desc.ordering]
1035 # This only supports primitives that map to C calls
1036 assert desc.c_function_name is not None
1037 self.assert_emit(
1038 CallC(
1039 desc.c_function_name,
1040 args,
1041 desc.return_type,
1042 desc.steals,
1043 desc.is_borrowed,
1044 desc.error_kind,
1045 55,
1046 ),
1047 expected,
1048 )
1049 return
1050 else:
1051 assert False, "Could not find matching op"
1052
1053
1054class TestGenerateFunction(unittest.TestCase):

Callers 3

test_int_addMethod · 0.95
test_int_subMethod · 0.95
test_dict_containsMethod · 0.95

Calls 3

assert_emitMethod · 0.95
is_subtypeFunction · 0.90
CallCClass · 0.90

Tested by

no test coverage detected