summaryrefslogtreecommitdiff
path: root/tests/run/ctuple.pyx
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run/ctuple.pyx')
-rw-r--r--tests/run/ctuple.pyx29
1 files changed, 26 insertions, 3 deletions
diff --git a/tests/run/ctuple.pyx b/tests/run/ctuple.pyx
index 9412a2cc3..88cfdddfb 100644
--- a/tests/run/ctuple.pyx
+++ b/tests/run/ctuple.pyx
@@ -1,5 +1,8 @@
+# mode: run
+
import cython
+
def simple_convert(*o):
"""
>>> simple_convert(1, 2)
@@ -8,15 +11,35 @@ def simple_convert(*o):
>>> simple_convert(1)
Traceback (most recent call last):
...
- TypeError: Expected a tuple of size 2, got size 1
+ TypeError: Expected a sequence of size 2, got size 1
>>> simple_convert(1, 2, 3)
Traceback (most recent call last):
...
- TypeError: Expected a tuple of size 2, got size 3
+ TypeError: Expected a sequence of size 2, got size 3
"""
cdef (int, double) xy = o
return xy
+
+def convert_from_list(*o):
+ """
+ >>> convert_from_list(1, 2)
+ (1, 2.0)
+
+ >>> convert_from_list(1)
+ Traceback (most recent call last):
+ ...
+ TypeError: Expected a sequence of size 2, got size 1
+ >>> convert_from_list(1, 2, 3)
+ Traceback (most recent call last):
+ ...
+ TypeError: Expected a sequence of size 2, got size 3
+ """
+ cdef object values = list(o)
+ cdef (int, double) xy = values
+ return xy
+
+
def indexing((int, double) xy):
"""
>>> indexing((1, 2))
@@ -231,7 +254,7 @@ def test_mul_to_ctuple((int, int) ab, int c):
(1, 2, 1, 2)
>>> test_mul_to_ctuple((1, 2), 3)
Traceback (most recent call last):
- TypeError: Expected a tuple of size 4, got size 6
+ TypeError: Expected a sequence of size 4, got size 6
"""
result: tuple[cython.int, cython.int, cython.int, cython.int] = ab * c
return result