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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
3a712b6e
Commit
3a712b6e
authored
Oct 04, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parse tree test assertions for optimisations on loops and comprehensions
parent
4dd72eb9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
0 deletions
+34
-0
tests/run/dictcomp.pyx
tests/run/dictcomp.pyx
+6
-0
tests/run/enumerate_T316.pyx
tests/run/enumerate_T316.pyx
+13
-0
tests/run/for_in_range_T372.pyx
tests/run/for_in_range_T372.pyx
+10
-0
tests/run/setcomp.pyx
tests/run/setcomp.pyx
+5
-0
No files found.
tests/run/dictcomp.pyx
View file @
3a712b6e
...
...
@@ -15,11 +15,17 @@ True
[(1, 'a'), (2, 'b'), (3, 'c')]
"""
cimport
cython
def
smoketest_dict
():
return
{
x
+
2
:
x
*
2
for
x
in
range
(
5
)
if
x
%
2
==
0
}
@
cython
.
testFailIfPathExists
(
"//ComprehensionNode//ComprehensionAppendNode"
,
"//SimpleCallNode//ComprehensionNode"
)
@
cython
.
testAssertPathExists
(
"//ComprehensionNode"
,
"//ComprehensionNode//DictComprehensionAppendNode"
)
def
smoketest_list
():
return
dict
([
(
x
+
2
,
x
*
2
)
for
x
in
range
(
5
)
...
...
tests/run/enumerate_T316.pyx
View file @
3a712b6e
...
...
@@ -63,20 +63,26 @@ __doc__ = u"""
"""
cimport
cython
@
cython
.
testFailIfPathExists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
def
go_py_enumerate
():
for
i
,
k
in
enumerate
(
range
(
1
,
5
)):
print
i
,
k
@
cython
.
testFailIfPathExists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
def
go_c_enumerate
():
cdef
int
i
,
k
for
i
,
k
in
enumerate
(
range
(
1
,
5
)):
print
i
,
k
@
cython
.
testFailIfPathExists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
def
go_c_enumerate_step
():
cdef
int
i
,
k
for
i
,
k
in
enumerate
(
range
(
1
,
7
,
2
)):
print
i
,
k
@
cython
.
testFailIfPathExists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
def
py_enumerate_dict
(
dict
d
):
cdef
int
i
=
55
k
=
99
...
...
@@ -84,6 +90,7 @@ def py_enumerate_dict(dict d):
print
i
,
k
print
u"::"
,
i
,
k
@
cython
.
testFailIfPathExists
(
"//SimpleCallNode"
)
def
py_enumerate_break
(
*
t
):
i
,
k
=
55
,
99
for
i
,
k
in
enumerate
(
t
):
...
...
@@ -91,6 +98,7 @@ def py_enumerate_break(*t):
break
print
u"::"
,
i
,
k
@
cython
.
testFailIfPathExists
(
"//SimpleCallNode"
)
def
py_enumerate_return
(
*
t
):
i
,
k
=
55
,
99
for
i
,
k
in
enumerate
(
t
):
...
...
@@ -98,6 +106,7 @@ def py_enumerate_return(*t):
return
print
u"::"
,
i
,
k
@
cython
.
testFailIfPathExists
(
"//SimpleCallNode"
)
def
py_enumerate_continue
(
*
t
):
i
,
k
=
55
,
99
for
i
,
k
in
enumerate
(
t
):
...
...
@@ -105,20 +114,24 @@ def py_enumerate_continue(*t):
continue
print
u"::"
,
i
,
k
@
cython
.
testFailIfPathExists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
def
empty_c_enumerate
():
cdef
int
i
=
55
,
k
=
99
for
i
,
k
in
enumerate
(
range
(
0
)):
print
i
,
k
return
i
,
k
# not currently optimised
def
single_target_enumerate
():
for
t
in
enumerate
(
range
(
1
,
5
)):
print
t
[
0
],
t
[
1
]
@
cython
.
testFailIfPathExists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
def
multi_enumerate
():
for
a
,(
b
,(
c
,
d
))
in
enumerate
(
enumerate
(
enumerate
(
range
(
1
,
5
)))):
print
a
,
b
,
c
,
d
@
cython
.
testFailIfPathExists
(
"//SimpleCallNode"
)
def
multi_c_enumerate
():
cdef
int
a
,
b
,
c
,
d
for
a
,(
b
,(
c
,
d
))
in
enumerate
(
enumerate
(
enumerate
(
range
(
1
,
5
)))):
...
...
tests/run/for_in_range_T372.pyx
View file @
3a712b6e
...
...
@@ -13,6 +13,10 @@ __doc__ = u"""
(2, 0)
"""
cimport
cython
@
cython
.
testAssertPathExists
(
"//ForFromStatNode"
)
@
cython
.
testFailIfPathExists
(
"//ForInStatNode"
)
def
test_modify
():
cdef
int
i
,
n
=
5
for
i
in
range
(
n
):
...
...
@@ -21,6 +25,8 @@ def test_modify():
print
return
i
,
n
@
cython
.
testAssertPathExists
(
"//ForFromStatNode"
)
@
cython
.
testFailIfPathExists
(
"//ForInStatNode"
)
def
test_fix
():
cdef
int
i
for
i
in
range
(
5
):
...
...
@@ -28,6 +34,8 @@ def test_fix():
print
return
i
@
cython
.
testAssertPathExists
(
"//ForFromStatNode"
)
@
cython
.
testFailIfPathExists
(
"//ForInStatNode"
)
def
test_break
():
cdef
int
i
,
n
=
5
for
i
in
range
(
n
):
...
...
@@ -38,6 +46,8 @@ def test_break():
print
return
i
,
n
@
cython
.
testAssertPathExists
(
"//ForFromStatNode"
)
@
cython
.
testFailIfPathExists
(
"//ForInStatNode"
)
def
test_return
():
cdef
int
i
,
n
=
5
for
i
in
range
(
n
):
...
...
tests/run/setcomp.pyx
View file @
3a712b6e
...
...
@@ -17,6 +17,8 @@ True
[1, 2, 3]
"""
cimport
cython
# Py2.3 doesn't have the set type, but Cython does :)
_set
=
set
...
...
@@ -25,6 +27,9 @@ def smoketest_set():
for
x
in
range
(
5
)
if
x
%
2
==
0
}
@
cython
.
testFailIfPathExists
(
"//SimpleCallNode//ComprehensionNode"
)
@
cython
.
testAssertPathExists
(
"//ComprehensionNode"
,
"//ComprehensionNode//ComprehensionAppendNode"
)
def
smoketest_list
():
return
set
([
x
*
2
for
x
in
range
(
5
)
...
...
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