summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2014-02-22 07:37:31 +0100
committerStefan Behnel <stefan_ml@behnel.de>2014-02-22 07:37:31 +0100
commita13dfd847a74cfb2311384b8398adf15cb5a99c8 (patch)
treec73eaaa06af5928fb8106bb5d37bf3a56f256ab7
parent52b2007b50555afb11d4657bfcd8040e57044466 (diff)
downloadcython-a13dfd847a74cfb2311384b8398adf15cb5a99c8.tar.gz
extend tuple tests to cover recent C code simplifications
-rw-r--r--tests/run/tuple.pyx49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/run/tuple.pyx b/tests/run/tuple.pyx
index aac58418c..d0c3d6f75 100644
--- a/tests/run/tuple.pyx
+++ b/tests/run/tuple.pyx
@@ -1,4 +1,7 @@
+cimport cython
+
+
def f(obj1, obj2, obj3, obj4, obj5):
"""
>>> f(1,2,3,4,5)
@@ -7,6 +10,7 @@ def f(obj1, obj2, obj3, obj4, obj5):
obj1 = ()
return obj1
+
def g(obj1, obj2, obj3, obj4, obj5):
"""
>>> g(1,2,3,4,5)
@@ -16,6 +20,7 @@ def g(obj1, obj2, obj3, obj4, obj5):
obj1 = (obj2,)
return obj1
+
def h(obj1, obj2, obj3, obj4, obj5):
"""
>>> h(1,2,3,4,5)
@@ -26,6 +31,7 @@ def h(obj1, obj2, obj3, obj4, obj5):
obj1 = obj2, obj3
return obj1
+
def j(obj1, obj2, obj3, obj4, obj5):
"""
>>> j(1,2,3,4,5)
@@ -37,6 +43,7 @@ def j(obj1, obj2, obj3, obj4, obj5):
obj1 = (obj2, obj3, obj4)
return obj1
+
def k(obj1, obj2, obj3, obj4, obj5):
"""
>>> k(1,2,3,4,5)
@@ -49,6 +56,7 @@ def k(obj1, obj2, obj3, obj4, obj5):
obj1 = (obj2, obj3, obj4,)
return obj1
+
def l(obj1, obj2, obj3, obj4, obj5):
"""
>>> l(1,2,3,4,5)
@@ -62,6 +70,7 @@ def l(obj1, obj2, obj3, obj4, obj5):
obj1 = 17, 42, 88
return obj1
+
def tuple_none():
"""
>>> tuple_none() # doctest: +ELLIPSIS
@@ -70,6 +79,7 @@ def tuple_none():
"""
return tuple(None)
+
def tuple_none_list():
"""
>>> tuple_none_list() # doctest: +ELLIPSIS
@@ -78,3 +88,42 @@ def tuple_none_list():
"""
cdef list none = None
return tuple(none)
+
+
+@cython.test_fail_if_path_exists(
+ '//SimpleCallNode',
+ '//PythonCapiCallNode'
+)
+def tuple_of_tuple_literal():
+ """
+ >>> tuple_of_tuple_literal()
+ (1, 2, 3)
+ """
+ return tuple(tuple(tuple((1,2,3))))
+
+
+@cython.test_fail_if_path_exists(
+ '//SimpleCallNode',
+ '//PythonCapiCallNode'
+)
+def tuple_of_args_tuple(*args):
+ """
+ >>> tuple_of_args_tuple(1,2,3)
+ (1, 2, 3)
+ """
+ return tuple(tuple(tuple(args)))
+
+
+@cython.test_fail_if_path_exists(
+ '//SimpleCallNode//SimpleCallNode',
+ '//PythonCapiCallNode'
+)
+def tuple_of_tuple_or_none(tuple x):
+ """
+ >>> tuple_of_tuple_or_none((1,2,3))
+ (1, 2, 3)
+ >>> tuple_of_tuple_or_none(None) # doctest: +ELLIPSIS
+ Traceback (most recent call last):
+ TypeError: ...iterable...
+ """
+ return tuple(tuple(tuple(x)))