mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
gh-116417: Move limited C API complex.c tests to _testlimitedcapi (#117014)
Split complex.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi.
This commit is contained in:
parent
7f64ae30dd
commit
61c659e2dc
8 changed files with 92 additions and 67 deletions
|
|
@ -163,7 +163,7 @@
|
|||
@MODULE__TESTBUFFER_TRUE@_testbuffer _testbuffer.c
|
||||
@MODULE__TESTINTERNALCAPI_TRUE@_testinternalcapi _testinternalcapi.c _testinternalcapi/test_lock.c _testinternalcapi/pytime.c _testinternalcapi/set.c _testinternalcapi/test_critical_sections.c
|
||||
@MODULE__TESTCAPI_TRUE@_testcapi _testcapimodule.c _testcapi/vectorcall.c _testcapi/heaptype.c _testcapi/abstract.c _testcapi/unicode.c _testcapi/dict.c _testcapi/set.c _testcapi/list.c _testcapi/tuple.c _testcapi/getargs.c _testcapi/datetime.c _testcapi/docstring.c _testcapi/mem.c _testcapi/watchers.c _testcapi/long.c _testcapi/float.c _testcapi/complex.c _testcapi/numbers.c _testcapi/structmember.c _testcapi/exceptions.c _testcapi/code.c _testcapi/buffer.c _testcapi/pyatomic.c _testcapi/file.c _testcapi/codec.c _testcapi/immortal.c _testcapi/gc.c _testcapi/hash.c _testcapi/time.c
|
||||
@MODULE__TESTLIMITEDCAPI_TRUE@_testlimitedcapi _testlimitedcapi.c _testlimitedcapi/abstract.c _testlimitedcapi/bytearray.c _testlimitedcapi/bytes.c _testlimitedcapi/dict.c _testlimitedcapi/float.c _testlimitedcapi/heaptype_relative.c _testlimitedcapi/list.c _testlimitedcapi/long.c _testlimitedcapi/pyos.c _testlimitedcapi/set.c _testlimitedcapi/sys.c _testlimitedcapi/unicode.c _testlimitedcapi/vectorcall_limited.c
|
||||
@MODULE__TESTLIMITEDCAPI_TRUE@_testlimitedcapi _testlimitedcapi.c _testlimitedcapi/abstract.c _testlimitedcapi/bytearray.c _testlimitedcapi/bytes.c _testlimitedcapi/complex.c _testlimitedcapi/dict.c _testlimitedcapi/float.c _testlimitedcapi/heaptype_relative.c _testlimitedcapi/list.c _testlimitedcapi/long.c _testlimitedcapi/pyos.c _testlimitedcapi/set.c _testlimitedcapi/sys.c _testlimitedcapi/unicode.c _testlimitedcapi/vectorcall_limited.c
|
||||
@MODULE__TESTCLINIC_TRUE@_testclinic _testclinic.c
|
||||
@MODULE__TESTCLINIC_LIMITED_TRUE@_testclinic_limited _testclinic_limited.c
|
||||
|
||||
|
|
|
|||
|
|
@ -2,20 +2,6 @@
|
|||
#include "util.h"
|
||||
|
||||
|
||||
static PyObject *
|
||||
complex_check(PyObject *Py_UNUSED(module), PyObject *obj)
|
||||
{
|
||||
NULLABLE(obj);
|
||||
return PyLong_FromLong(PyComplex_Check(obj));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
complex_checkexact(PyObject *Py_UNUSED(module), PyObject *obj)
|
||||
{
|
||||
NULLABLE(obj);
|
||||
return PyLong_FromLong(PyComplex_CheckExact(obj));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
complex_fromccomplex(PyObject *Py_UNUSED(module), PyObject *obj)
|
||||
{
|
||||
|
|
@ -28,48 +14,6 @@ complex_fromccomplex(PyObject *Py_UNUSED(module), PyObject *obj)
|
|||
return PyComplex_FromCComplex(complex);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
complex_fromdoubles(PyObject *Py_UNUSED(module), PyObject *args)
|
||||
{
|
||||
double real, imag;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "dd", &real, &imag)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return PyComplex_FromDoubles(real, imag);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
complex_realasdouble(PyObject *Py_UNUSED(module), PyObject *obj)
|
||||
{
|
||||
double real;
|
||||
|
||||
NULLABLE(obj);
|
||||
real = PyComplex_RealAsDouble(obj);
|
||||
|
||||
if (real == -1. && PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble(real);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
complex_imagasdouble(PyObject *Py_UNUSED(module), PyObject *obj)
|
||||
{
|
||||
double imag;
|
||||
|
||||
NULLABLE(obj);
|
||||
imag = PyComplex_ImagAsDouble(obj);
|
||||
|
||||
if (imag == -1. && PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble(imag);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
complex_asccomplex(PyObject *Py_UNUSED(module), PyObject *obj)
|
||||
{
|
||||
|
|
@ -139,12 +83,7 @@ _py_c_abs(PyObject *Py_UNUSED(module), PyObject* obj)
|
|||
|
||||
|
||||
static PyMethodDef test_methods[] = {
|
||||
{"complex_check", complex_check, METH_O},
|
||||
{"complex_checkexact", complex_checkexact, METH_O},
|
||||
{"complex_fromccomplex", complex_fromccomplex, METH_O},
|
||||
{"complex_fromdoubles", complex_fromdoubles, METH_VARARGS},
|
||||
{"complex_realasdouble", complex_realasdouble, METH_O},
|
||||
{"complex_imagasdouble", complex_imagasdouble, METH_O},
|
||||
{"complex_asccomplex", complex_asccomplex, METH_O},
|
||||
{"_py_c_sum", _py_c_sum, METH_VARARGS},
|
||||
{"_py_c_diff", _py_c_diff, METH_VARARGS},
|
||||
|
|
|
|||
|
|
@ -35,6 +35,9 @@ PyInit__testlimitedcapi(void)
|
|||
if (_PyTestLimitedCAPI_Init_Bytes(mod) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (_PyTestLimitedCAPI_Init_Complex(mod) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (_PyTestLimitedCAPI_Init_Dict(mod) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
79
Modules/_testlimitedcapi/complex.c
Normal file
79
Modules/_testlimitedcapi/complex.c
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
#include "parts.h"
|
||||
#include "util.h"
|
||||
|
||||
|
||||
static PyObject *
|
||||
complex_check(PyObject *Py_UNUSED(module), PyObject *obj)
|
||||
{
|
||||
NULLABLE(obj);
|
||||
return PyLong_FromLong(PyComplex_Check(obj));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
complex_checkexact(PyObject *Py_UNUSED(module), PyObject *obj)
|
||||
{
|
||||
NULLABLE(obj);
|
||||
return PyLong_FromLong(PyComplex_CheckExact(obj));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
complex_fromdoubles(PyObject *Py_UNUSED(module), PyObject *args)
|
||||
{
|
||||
double real, imag;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "dd", &real, &imag)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return PyComplex_FromDoubles(real, imag);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
complex_realasdouble(PyObject *Py_UNUSED(module), PyObject *obj)
|
||||
{
|
||||
double real;
|
||||
|
||||
NULLABLE(obj);
|
||||
real = PyComplex_RealAsDouble(obj);
|
||||
|
||||
if (real == -1. && PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble(real);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
complex_imagasdouble(PyObject *Py_UNUSED(module), PyObject *obj)
|
||||
{
|
||||
double imag;
|
||||
|
||||
NULLABLE(obj);
|
||||
imag = PyComplex_ImagAsDouble(obj);
|
||||
|
||||
if (imag == -1. && PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble(imag);
|
||||
}
|
||||
|
||||
|
||||
static PyMethodDef test_methods[] = {
|
||||
{"complex_check", complex_check, METH_O},
|
||||
{"complex_checkexact", complex_checkexact, METH_O},
|
||||
{"complex_fromdoubles", complex_fromdoubles, METH_VARARGS},
|
||||
{"complex_realasdouble", complex_realasdouble, METH_O},
|
||||
{"complex_imagasdouble", complex_imagasdouble, METH_O},
|
||||
{NULL},
|
||||
};
|
||||
|
||||
int
|
||||
_PyTestLimitedCAPI_Init_Complex(PyObject *mod)
|
||||
{
|
||||
if (PyModule_AddFunctions(mod, test_methods) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -25,6 +25,7 @@
|
|||
int _PyTestLimitedCAPI_Init_Abstract(PyObject *module);
|
||||
int _PyTestLimitedCAPI_Init_ByteArray(PyObject *module);
|
||||
int _PyTestLimitedCAPI_Init_Bytes(PyObject *module);
|
||||
int _PyTestLimitedCAPI_Init_Complex(PyObject *module);
|
||||
int _PyTestLimitedCAPI_Init_Dict(PyObject *module);
|
||||
int _PyTestLimitedCAPI_Init_Float(PyObject *module);
|
||||
int _PyTestLimitedCAPI_Init_HeaptypeRelative(PyObject *module);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue