Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
da602065
Commit
da602065
authored
Sep 27, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate functions in test for readability.
parent
d283bd6c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
+16
-0
tests/run/listcomp.pyx
tests/run/listcomp.pyx
+16
-0
No files found.
tests/run/listcomp.pyx
View file @
da602065
# 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"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment