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
Gwenaël Samain
cython
Commits
1f7b40c4
Commit
1f7b40c4
authored
Dec 18, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more tests for for-loops and constant expressions
parent
336846c5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
0 deletions
+32
-0
tests/run/consts.pyx
tests/run/consts.pyx
+13
-0
tests/run/r_forloop.pyx
tests/run/r_forloop.pyx
+19
-0
No files found.
tests/run/consts.pyx
View file @
1f7b40c4
...
...
@@ -3,25 +3,38 @@ __doc__ = u"""
True
>>> add_var(10) == 1+2+10+3+4
True
>>> neg() == -1 -2 - (-3+4)
True
>>> mul() == 1*60*1000
True
>>> arithm() == 9*2+3*8/6-10
True
>>> parameters() == _func(-1 -2, - (-3+4), 1*2*3)
True
>>> lists() == [1,2,3] + [4,5,6]
True
"""
def
_func
(
a
,
b
,
c
):
return
a
+
b
+
c
def
add
():
return
1
+
2
+
3
+
4
def
add_var
(
a
):
return
1
+
2
+
a
+
3
+
4
def
neg
():
return
-
1
-
2
-
(
-
3
+
4
)
def
mul
():
return
1
*
60
*
1000
def
arithm
():
return
9
*
2
+
3
*
8
/
6
-
10
def
parameters
():
return
_func
(
-
1
-
2
,
-
(
-
3
+
4
),
1
*
2
*
3
)
def
lists
():
return
[
1
,
2
,
3
]
+
[
4
,
5
,
6
]
tests/run/r_forloop.pyx
View file @
1f7b40c4
...
...
@@ -21,6 +21,9 @@ __doc__ = u"""
>>> go_c_all_exprs(3)
Spam!
Spam!
>>> go_c_const_exprs()
Spam!
Spam!
>>> go_c_calc(2)
Spam!
Spam!
...
...
@@ -52,6 +55,9 @@ __doc__ = u"""
Spam!
>>> go_dict_ret()
2
>>> global_result
6
"""
def
go_py
():
...
...
@@ -78,6 +84,11 @@ def go_c_all_exprs(x):
for
i
in
range
(
4
*
x
,
2
*
x
,
-
3
):
print
u"Spam!"
def
go_c_const_exprs
():
cdef
int
i
for
i
in
range
(
4
*
2
+
1
,
2
*
2
,
-
2
-
1
):
print
u"Spam!"
def
f
(
x
):
return
2
*
x
...
...
@@ -130,3 +141,11 @@ def go_dict_ret():
for
i
in
d
:
if
i
>
1
and
i
<
3
:
return
i
# test global scope also
global_result
=
None
cdef
int
i
for
i
in
range
(
4
*
2
+
1
,
2
*
2
,
-
2
-
1
):
if
i
<
7
:
global_result
=
i
break
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