summaryrefslogtreecommitdiff
path: root/tests/run/cfuncptr.pyx
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run/cfuncptr.pyx')
-rw-r--r--tests/run/cfuncptr.pyx41
1 files changed, 41 insertions, 0 deletions
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()