Commit 1f7b40c4 authored by Stefan Behnel's avatar Stefan Behnel

more tests for for-loops and constant expressions

parent 336846c5
......@@ -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]
......@@ -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
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