diff options
Diffstat (limited to 'tests/run/cfuncptr.pyx')
-rw-r--r-- | tests/run/cfuncptr.pyx | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/tests/run/cfuncptr.pyx b/tests/run/cfuncptr.pyx index b7018cce0..cb3b32184 100644 --- a/tests/run/cfuncptr.pyx +++ b/tests/run/cfuncptr.pyx @@ -46,15 +46,49 @@ cdef int exceptminus2(int bad) except -2: else: return 0 -def call_exceptminus2(bad): +def call_exceptminus2_through_exceptstar_pointer(bad): """ - >>> call_exceptminus2(True) + >>> call_exceptminus2_through_exceptstar_pointer(True) Traceback (most recent call last): ... RuntimeError - >>> call_exceptminus2(False) + >>> call_exceptminus2_through_exceptstar_pointer(False) 0 """ cdef int (*fptr)(int) except * # GH4770 - should not be treated as except? -1 fptr = exceptminus2 return fptr(bad) + +def call_exceptminus2_through_exceptmaybeminus2_pointer(bad): + """ + >>> call_exceptminus2_through_exceptmaybeminus2_pointer(True) + Traceback (most recent call last): + ... + RuntimeError + >>> call_exceptminus2_through_exceptmaybeminus2_pointer(False) + 0 + """ + cdef int (*fptr)(int) except ?-2 # exceptions should be compatible + fptr = exceptminus2 + return fptr(bad) + +cdef int noexcept_func(): # noexcept + return 0 + +def call_noexcept_func_except_star(): + """ + >>> call_noexcept_func_except_star() + 0 + """ + cdef int (*fptr)() except * + fptr = noexcept_func # exception specifications are compatible + return fptr() + +def call_noexcept_func_except_check(): + """ + >>> call_noexcept_func_except_check() + 0 + """ + cdef int (*fptr)() except ?-1 + fptr = noexcept_func # exception specifications are compatible + return fptr() |