Commit e651bec3 authored by da-woods's avatar da-woods Committed by GitHub

Add more cimport_from_pyx tests (GH-3786)

There's now a fairly wide range of valid syntax for declaring things in pyx files and it should all be supported when cimporting from them.
parent fcfd16c7
......@@ -15,14 +15,22 @@ setup(
######## a.pyx ########
from b cimport Bclass, Bfunc, Bstruct, Benum, Benum_value, Btypedef, Py_EQ, Py_NE
from b cimport (Bclass, Bfunc, Bstruct, Benum, Benum_value, Btypedef, Py_EQ, Py_NE,
DecoratedClass, cfuncOutside)
cdef Bclass b = Bclass(5)
assert Bfunc(&b.value) == b.value
assert b.anotherValue == 6, b.anotherValue
assert b.asStruct().value == b.value
cdef Btypedef b_type = &b.value
cdef Benum b_enum = Benum_value
cdef int tmp = Py_EQ
cdef DecoratedClass dc = DecoratedClass()
assert dc.cfuncInClass().value == 5
assert dc.cpdefInClass() == 1.0
assert cfuncOutside().value == 2
#from c cimport ClassC
#cdef ClassC c = ClassC()
#print c.value
......@@ -31,6 +39,8 @@ cdef int tmp = Py_EQ
from cpython.object cimport Py_EQ, Py_NE
cimport cython
cdef enum Benum:
Benum_value
......@@ -41,14 +51,34 @@ ctypedef long *Btypedef
cdef class Bclass:
cdef long value
anotherValue: cython.double
def __init__(self, value):
self.value = value
self.anotherValue = value + 1
cdef Bstruct asStruct(self):
return Bstruct(value=self.value)
cdef double getOtherValue(self):
return self.anotherValue
cdef long Bfunc(Btypedef x):
return x[0]
@cython.cclass
class DecoratedClass:
@cython.cfunc
@cython.returns(Bstruct)
def cfuncInClass(self):
return Bstruct(value=5)
@cython.ccall
@cython.returns(cython.double)
def cpdefInClass(self):
return 1.0
@cython.cfunc
@cython.returns(Bstruct)
def cfuncOutside():
return Bstruct(value=2)
######## c.pxd ########
cdef class ClassC:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment