summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2018-08-03 17:38:50 +0200
committerStefan Behnel <stefan_ml@behnel.de>2018-08-03 17:38:50 +0200
commitc48d7bb7f677bbcf616051594f0cc40d0fd0029b (patch)
tree6da6b460ab92014fe0321fed16e2aacabc2f9b00
parenteae37760bfbe19e7469aa41269480b84ce12b6cd (diff)
downloadcython-c48d7bb7f677bbcf616051594f0cc40d0fd0029b.tar.gz
Enable some tests that were unintentionally not being executed because docstrings in cdef functions are not visible to Python.
-rw-r--r--tests/run/pure_py.py30
-rw-r--r--tests/run/pure_py3.py18
2 files changed, 24 insertions, 24 deletions
diff --git a/tests/run/pure_py.py b/tests/run/pure_py.py
index b52517a3a..72218d910 100644
--- a/tests/run/pure_py.py
+++ b/tests/run/pure_py.py
@@ -209,6 +209,10 @@ def test_declare_c_types(n):
@cython.ccall
@cython.returns(cython.double)
def c_call(x):
+ return x
+
+
+def call_ccall(x):
"""
Test that a declared return type is honoured when compiled.
@@ -224,10 +228,6 @@ def c_call(x):
>>> (is_compiled and 1) or result
1
"""
- return x
-
-
-def call_ccall(x):
ret = c_call(x)
return ret, cython.typeof(ret)
@@ -236,9 +236,13 @@ def call_ccall(x):
@cython.inline
@cython.returns(cython.double)
def cdef_inline(x):
+ return x + 1
+
+
+def call_cdef_inline(x):
"""
>>> result, return_type = call_cdef_inline(1)
- >>> (not is_compiled and 'float') or type(return_type).__name__
+ >>> (not is_compiled and 'float') or type(result).__name__
'float'
>>> (not is_compiled and 'double') or return_type
'double'
@@ -247,10 +251,6 @@ def cdef_inline(x):
>>> result == 2.0 or result
True
"""
- return x + 1
-
-
-def call_cdef_inline(x):
ret = cdef_inline(x)
return ret, cython.typeof(ret)
@@ -293,6 +293,12 @@ def ccall_except(x):
@cython.returns(cython.long)
@cython.exceptval(-1)
def cdef_except(x):
+ if x == 0:
+ raise ValueError
+ return x+1
+
+
+def call_cdef_except(x):
"""
>>> call_cdef_except(41)
42
@@ -300,12 +306,6 @@ def cdef_except(x):
Traceback (most recent call last):
ValueError
"""
- if x == 0:
- raise ValueError
- return x+1
-
-
-def call_cdef_except(x):
return cdef_except(x)
diff --git a/tests/run/pure_py3.py b/tests/run/pure_py3.py
index 1e07b59fd..4217ca43f 100644
--- a/tests/run/pure_py3.py
+++ b/tests/run/pure_py3.py
@@ -42,6 +42,10 @@ def test_struct(n: cython.int, x: cython.double) -> MyStruct2:
@cython.ccall
def c_call(x) -> cython.double:
+ return x
+
+
+def call_ccall(x):
"""
Test that a declared return type is honoured when compiled.
@@ -57,10 +61,6 @@ def c_call(x) -> cython.double:
>>> (is_compiled and 1) or result
1
"""
- return x
-
-
-def call_ccall(x):
ret = c_call(x)
return ret, cython.typeof(ret)
@@ -68,9 +68,13 @@ def call_ccall(x):
@cython.cfunc
@cython.inline
def cdef_inline(x) -> cython.double:
+ return x + 1
+
+
+def call_cdef_inline(x):
"""
>>> result, return_type = call_cdef_inline(1)
- >>> (not is_compiled and 'float') or type(return_type).__name__
+ >>> (not is_compiled and 'float') or type(result).__name__
'float'
>>> (not is_compiled and 'double') or return_type
'double'
@@ -79,9 +83,5 @@ def cdef_inline(x) -> cython.double:
>>> result == 2.0 or result
True
"""
- return x + 1
-
-
-def call_cdef_inline(x):
ret = cdef_inline(x)
return ret, cython.typeof(ret)