Commit da602065 authored by Stefan Behnel's avatar Stefan Behnel

Separate functions in test for readability.

parent d283bd6c
# mode: run
# tag: listcomp, comprehension
cimport cython
def smoketest():
"""
>>> smoketest()
......@@ -10,6 +14,7 @@ def smoketest():
assert x != 'abc'
return result
def list_genexp():
"""
>>> list_genexp()
......@@ -20,6 +25,7 @@ def list_genexp():
assert x == 'abc'
return result
def int_runvar():
"""
>>> int_runvar()
......@@ -28,6 +34,7 @@ def int_runvar():
cdef int x
print [x*2 for x in range(5) if x % 2 == 0]
cdef class A:
def __repr__(self): return u"A"
......@@ -39,6 +46,7 @@ def typed():
cdef A obj
print [obj for obj in [A(), A(), A()]]
def inferred_type():
"""
>>> inferred_type()
......@@ -46,6 +54,7 @@ def inferred_type():
"""
print [cython.typeof(obj) for obj in [A(), A(), A()]]
def not_inferred_type():
"""
>>> not_inferred_type()
......@@ -53,6 +62,7 @@ def not_inferred_type():
"""
print [cython.typeof(obj) for obj in [1, A(), 'abc']]
def iterdict():
"""
>>> iterdict()
......@@ -63,6 +73,7 @@ def iterdict():
l.sort()
print l
listcomp_result = [ i*i for i in range(5) ]
def global_listcomp():
"""
......@@ -72,6 +83,7 @@ def global_listcomp():
[0, 1, 4, 9, 16]
"""
def nested_result():
"""
>>> nested_result()
......@@ -80,6 +92,7 @@ def nested_result():
result = [[a-1 for a in range(b)] for b in range(4)]
return result
def listcomp_as_condition(sequence):
"""
>>> listcomp_as_condition(['a', 'b', '+'])
......@@ -93,6 +106,7 @@ def listcomp_as_condition(sequence):
return True
return False
@cython.test_fail_if_path_exists("//SimpleCallNode//ComprehensionNode")
@cython.test_assert_path_exists("//ComprehensionNode")
def sorted_listcomp(sequence):
......@@ -106,6 +120,7 @@ def sorted_listcomp(sequence):
"""
return sorted([ n+1 for n in sequence ])
@cython.test_fail_if_path_exists("//IfStatNode",
"//ComprehensionAppendNode")
@cython.test_assert_path_exists("//ComprehensionNode")
......@@ -116,6 +131,7 @@ def listcomp_const_condition_false():
"""
return [x*2 for x in range(3) if False]
@cython.test_fail_if_path_exists("//IfStatNode")
@cython.test_assert_path_exists("//ComprehensionNode",
"//ComprehensionAppendNode")
......
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