diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2021-10-02 11:08:43 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2021-10-02 11:08:58 +0200 |
commit | 97c05e7a936e1a8929ee8c3e2f6629cc061cb66b (patch) | |
tree | 5ed758564c4fea47e84df362a5292cc764625bf8 | |
parent | 8c7b0f3fb745aa7bd0afedfbeb862eecc5fdff0c (diff) | |
download | cython-97c05e7a936e1a8929ee8c3e2f6629cc061cb66b.tar.gz |
Make a compile test runnable.
-rw-r--r-- | tests/compile/funcptr.pyx | 12 | ||||
-rw-r--r-- | tests/run/cfuncptr.pyx | 41 |
2 files changed, 41 insertions, 12 deletions
diff --git a/tests/compile/funcptr.pyx b/tests/compile/funcptr.pyx deleted file mode 100644 index 504238358..000000000 --- a/tests/compile/funcptr.pyx +++ /dev/null @@ -1,12 +0,0 @@ -# mode: compile - -cdef int grail(): - cdef int (*spam)() - spam = &grail - spam = grail - spam() - -ctypedef int funcptr_t() - -cdef inline funcptr_t* dummy(): - return &grail diff --git a/tests/run/cfuncptr.pyx b/tests/run/cfuncptr.pyx new file mode 100644 index 000000000..8a2f664d1 --- /dev/null +++ b/tests/run/cfuncptr.pyx @@ -0,0 +1,41 @@ +# mode: run + + +cdef int grail(): + cdef int (*spam)() + spam = &grail + spam = grail + assert spam is grail + assert spam == grail + assert spam == &grail + + +ctypedef int funcptr_t() + +cdef funcptr_t* get_grail(): + return &grail + + +def test_assignments(): + """ + >>> test_assignments() + """ + grail() + + +def test_return_value(): + """ + >>> test_return_value() + True + """ + g = get_grail() + return g == &grail + + +def call_cfuncptr(): + """ + >>> call_cfuncptr() + """ + cdef int (*spam)() + spam = grail + spam() |