Commit a13dfd84 authored by Stefan Behnel's avatar Stefan Behnel

extend tuple tests to cover recent C code simplifications

parent 52b2007b
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)))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment