(self)
| 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] |
nothing calls this directly
no test coverage detected