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

Method test_check_int

mypyc/test/test_emitwrapper.py:33–56  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

31 )
32
33 def test_check_int(self) -> None:
34 emitter = Emitter(self.context)
35 generate_arg_check("x", int_rprimitive, emitter, ReturnHandler("NULL"))
36 generate_arg_check("y", int_rprimitive, emitter, ReturnHandler("NULL"), optional=True)
37 lines = emitter.fragments
38 self.assert_lines(
39 [
40 "CPyTagged arg_x;",
41 "if (likely(PyLong_Check(obj_x)))",
42 " arg_x = CPyTagged_BorrowFromObject(obj_x);",
43 "else {",
44 ' CPy_TypeError("int", obj_x); return NULL;',
45 "}",
46 "CPyTagged arg_y;",
47 "if (obj_y == NULL) {",
48 " arg_y = CPY_INT_TAG;",
49 "} else if (likely(PyLong_Check(obj_y)))",
50 " arg_y = CPyTagged_BorrowFromObject(obj_y);",
51 "else {",
52 ' CPy_TypeError("int", obj_y); return NULL;',
53 "}",
54 ],
55 lines,
56 )
57
58 def assert_lines(self, expected: list[str], actual: list[str]) -> None:
59 actual = [line.rstrip("\n") for line in actual]

Callers

nothing calls this directly

Calls 4

assert_linesMethod · 0.95
EmitterClass · 0.90
generate_arg_checkFunction · 0.90
ReturnHandlerClass · 0.90

Tested by

no test coverage detected