1
1
#include "parts.h"
2
+ #include "clinic/long.c.h"
3
+
4
+ /*[clinic input]
5
+ module _testcapi
6
+ [clinic start generated code]*/
7
+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=6361033e795369fc]*/
2
8
3
9
4
10
static PyObject *
@@ -40,8 +46,13 @@ raise_test_long_error(const char* msg)
40
46
41
47
#include "testcapi_long.h"
42
48
49
+ /*[clinic input]
50
+ _testcapi.test_long_api
51
+ [clinic start generated code]*/
52
+
43
53
static PyObject *
44
- test_long_api (PyObject * self , PyObject * Py_UNUSED (ignored ))
54
+ _testcapi_test_long_api_impl (PyObject * module )
55
+ /*[clinic end generated code: output=4405798ca1e9f444 input=e9b8880d7331c688]*/
45
56
{
46
57
return TESTNAME (raise_test_long_error );
47
58
}
@@ -68,8 +79,13 @@ raise_test_longlong_error(const char* msg)
68
79
69
80
#include "testcapi_long.h"
70
81
82
+ /*[clinic input]
83
+ _testcapi.test_longlong_api
84
+ [clinic start generated code]*/
85
+
71
86
static PyObject *
72
- test_longlong_api (PyObject * self , PyObject * args )
87
+ _testcapi_test_longlong_api_impl (PyObject * module )
88
+ /*[clinic end generated code: output=2b3414ba8c31dfe6 input=ccbb2a48c2b3c4a5]*/
73
89
{
74
90
return TESTNAME (raise_test_longlong_error );
75
91
}
@@ -81,13 +97,19 @@ test_longlong_api(PyObject* self, PyObject *args)
81
97
#undef F_U_TO_PY
82
98
#undef F_PY_TO_U
83
99
84
- /* Test the PyLong_AsLongAndOverflow API. General conversion to PY_LONG
85
- is tested by test_long_api_inner. This test will concentrate on proper
86
- handling of overflow.
87
- */
100
+
101
+ /*[clinic input]
102
+ _testcapi.test_long_and_overflow
103
+
104
+ Test the PyLong_AsLongAndOverflow API.
105
+
106
+ General conversion to PY_LONG is tested by test_long_api_inner.
107
+ This test will concentrate on proper handling of overflow.
108
+ [clinic start generated code]*/
88
109
89
110
static PyObject *
90
- test_long_and_overflow (PyObject * self , PyObject * Py_UNUSED (ignored ))
111
+ _testcapi_test_long_and_overflow_impl (PyObject * module )
112
+ /*[clinic end generated code: output=f8460ca115e31d8e input=762f6b62da0a3cdc]*/
91
113
{
92
114
PyObject * num , * one , * temp ;
93
115
long value ;
@@ -243,13 +265,18 @@ test_long_and_overflow(PyObject *self, PyObject *Py_UNUSED(ignored))
243
265
Py_RETURN_NONE ;
244
266
}
245
267
246
- /* Test the PyLong_AsLongLongAndOverflow API. General conversion to
247
- long long is tested by test_long_api_inner. This test will
248
- concentrate on proper handling of overflow.
249
- */
268
+ /*[clinic input]
269
+ _testcapi.test_long_long_and_overflow
270
+
271
+ Test the PyLong_AsLongLongAndOverflow API.
272
+
273
+ General conversion to long long is tested by test_long_api_inner.
274
+ This test will concentrate on proper handling of overflow.
275
+ [clinic start generated code]*/
250
276
251
277
static PyObject *
252
- test_long_long_and_overflow (PyObject * self , PyObject * Py_UNUSED (ignored ))
278
+ _testcapi_test_long_long_and_overflow_impl (PyObject * module )
279
+ /*[clinic end generated code: output=0b92330786f45483 input=544bb0aefe5e8a9e]*/
253
280
{
254
281
PyObject * num , * one , * temp ;
255
282
long long value ;
@@ -405,13 +432,18 @@ test_long_long_and_overflow(PyObject *self, PyObject *Py_UNUSED(ignored))
405
432
Py_RETURN_NONE ;
406
433
}
407
434
408
- /* Test the PyLong_As{Size,Ssize}_t API. At present this just tests that
409
- non-integer arguments are handled correctly. It should be extended to
410
- test overflow handling.
411
- */
435
+ /*[clinic input]
436
+ _testcapi.test_long_as_size_t
437
+
438
+ Test the PyLong_As{Size,Ssize}_t API.
439
+
440
+ At present this just tests that non-integer arguments are handled correctly.
441
+ It should be extended to test overflow handling.
442
+ [clinic start generated code]*/
412
443
413
444
static PyObject *
414
- test_long_as_size_t (PyObject * self , PyObject * Py_UNUSED (ignored ))
445
+ _testcapi_test_long_as_size_t_impl (PyObject * module )
446
+ /*[clinic end generated code: output=f6490ea2b41e6173 input=922990c4a3edfb0d]*/
415
447
{
416
448
size_t out_u ;
417
449
Py_ssize_t out_s ;
@@ -442,9 +474,13 @@ test_long_as_size_t(PyObject *self, PyObject *Py_UNUSED(ignored))
442
474
return Py_None ;
443
475
}
444
476
477
+ /*[clinic input]
478
+ _testcapi.test_long_as_unsigned_long_long_mask
479
+ [clinic start generated code]*/
480
+
445
481
static PyObject *
446
- test_long_as_unsigned_long_long_mask (PyObject * self ,
447
- PyObject * Py_UNUSED ( ignored ))
482
+ _testcapi_test_long_as_unsigned_long_long_mask_impl (PyObject * module )
483
+ /*[clinic end generated code: output=e3e16cd0189440cc input=eb2438493ae7b9af]*/
448
484
{
449
485
unsigned long long res = PyLong_AsUnsignedLongLongMask (NULL );
450
486
@@ -462,12 +498,13 @@ test_long_as_unsigned_long_long_mask(PyObject *self,
462
498
Py_RETURN_NONE ;
463
499
}
464
500
465
- /* Test the PyLong_AsDouble API. At present this just tests that
466
- non-integer arguments are handled correctly.
467
- */
501
+ /*[clinic input]
502
+ _testcapi.test_long_as_double
503
+ [clinic start generated code] */
468
504
469
505
static PyObject *
470
- test_long_as_double (PyObject * self , PyObject * Py_UNUSED (ignored ))
506
+ _testcapi_test_long_as_double_impl (PyObject * module )
507
+ /*[clinic end generated code: output=deca0898e15adde5 input=c77bc88ef5a1de76]*/
471
508
{
472
509
double out ;
473
510
@@ -487,9 +524,13 @@ test_long_as_double(PyObject *self, PyObject *Py_UNUSED(ignored))
487
524
return Py_None ;
488
525
}
489
526
490
- /* Simple test of _PyLong_NumBits and _PyLong_Sign. */
527
+ /*[clinic input]
528
+ _testcapi.test_long_numbits
529
+ [clinic start generated code]*/
530
+
491
531
static PyObject *
492
- test_long_numbits (PyObject * self , PyObject * Py_UNUSED (ignored ))
532
+ _testcapi_test_long_numbits_impl (PyObject * module )
533
+ /*[clinic end generated code: output=9eaf8458cb15d7f7 input=265c02d48a13059e]*/
493
534
{
494
535
struct triple {
495
536
long input ;
@@ -534,8 +575,16 @@ test_long_numbits(PyObject *self, PyObject *Py_UNUSED(ignored))
534
575
Py_RETURN_NONE ;
535
576
}
536
577
578
+ /*[clinic input]
579
+ _testcapi.call_long_compact_api
580
+ arg: object
581
+ /
582
+ [clinic start generated code]*/
583
+
537
584
static PyObject *
538
- check_long_compact_api (PyObject * self , PyObject * arg )
585
+ _testcapi_call_long_compact_api (PyObject * module , PyObject * arg )
586
+ /*[clinic end generated code: output=7e3894f611b1b2b7 input=87b87396967af14c]*/
587
+
539
588
{
540
589
assert (PyLong_Check (arg ));
541
590
int is_compact = PyUnstable_Long_IsCompact ((PyLongObject * )arg );
@@ -547,15 +596,15 @@ check_long_compact_api(PyObject *self, PyObject *arg)
547
596
}
548
597
549
598
static PyMethodDef test_methods [] = {
550
- { "test_long_and_overflow" , test_long_and_overflow , METH_NOARGS },
551
- { "test_long_api" , test_long_api , METH_NOARGS },
552
- { "test_long_as_double" , test_long_as_double , METH_NOARGS },
553
- { "test_long_as_size_t" , test_long_as_size_t , METH_NOARGS },
554
- { "test_long_as_unsigned_long_long_mask" , test_long_as_unsigned_long_long_mask , METH_NOARGS },
555
- { "test_long_long_and_overflow" , test_long_long_and_overflow , METH_NOARGS },
556
- { "test_long_numbits" , test_long_numbits , METH_NOARGS },
557
- { "test_longlong_api" , test_longlong_api , METH_NOARGS },
558
- { "call_long_compact_api" , check_long_compact_api , METH_O },
599
+ _TESTCAPI_TEST_LONG_AND_OVERFLOW_METHODDEF
600
+ _TESTCAPI_TEST_LONG_API_METHODDEF
601
+ _TESTCAPI_TEST_LONG_AS_DOUBLE_METHODDEF
602
+ _TESTCAPI_TEST_LONG_AS_SIZE_T_METHODDEF
603
+ _TESTCAPI_TEST_LONG_AS_UNSIGNED_LONG_LONG_MASK_METHODDEF
604
+ _TESTCAPI_TEST_LONG_LONG_AND_OVERFLOW_METHODDEF
605
+ _TESTCAPI_TEST_LONG_NUMBITS_METHODDEF
606
+ _TESTCAPI_TEST_LONGLONG_API_METHODDEF
607
+ _TESTCAPI_CALL_LONG_COMPACT_API_METHODDEF
559
608
{NULL },
560
609
};
561
610
0 commit comments