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""" ...@@ -3,25 +3,38 @@ __doc__ = u"""
True True
>>> add_var(10) == 1+2+10+3+4 >>> add_var(10) == 1+2+10+3+4
True True
>>> neg() == -1 -2 - (-3+4)
True
>>> mul() == 1*60*1000 >>> mul() == 1*60*1000
True True
>>> arithm() == 9*2+3*8/6-10 >>> arithm() == 9*2+3*8/6-10
True True
>>> parameters() == _func(-1 -2, - (-3+4), 1*2*3)
True
>>> lists() == [1,2,3] + [4,5,6] >>> lists() == [1,2,3] + [4,5,6]
True True
""" """
def _func(a,b,c):
return a+b+c
def add(): def add():
return 1+2+3+4 return 1+2+3+4
def add_var(a): def add_var(a):
return 1+2 +a+ 3+4 return 1+2 +a+ 3+4
def neg():
return -1 -2 - (-3+4)
def mul(): def mul():
return 1*60*1000 return 1*60*1000
def arithm(): def arithm():
return 9*2+3*8/6-10 return 9*2+3*8/6-10
def parameters():
return _func(-1 -2, - (-3+4), 1*2*3)
def lists(): def lists():
return [1,2,3] + [4,5,6] return [1,2,3] + [4,5,6]
...@@ -21,6 +21,9 @@ __doc__ = u""" ...@@ -21,6 +21,9 @@ __doc__ = u"""
>>> go_c_all_exprs(3) >>> go_c_all_exprs(3)
Spam! Spam!
Spam! Spam!
>>> go_c_const_exprs()
Spam!
Spam!
>>> go_c_calc(2) >>> go_c_calc(2)
Spam! Spam!
Spam! Spam!
...@@ -52,6 +55,9 @@ __doc__ = u""" ...@@ -52,6 +55,9 @@ __doc__ = u"""
Spam! Spam!
>>> go_dict_ret() >>> go_dict_ret()
2 2
>>> global_result
6
""" """
def go_py(): def go_py():
...@@ -78,6 +84,11 @@ def go_c_all_exprs(x): ...@@ -78,6 +84,11 @@ def go_c_all_exprs(x):
for i in range(4*x,2*x,-3): for i in range(4*x,2*x,-3):
print u"Spam!" 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): def f(x):
return 2*x return 2*x
...@@ -130,3 +141,11 @@ def go_dict_ret(): ...@@ -130,3 +141,11 @@ def go_dict_ret():
for i in d: for i in d:
if i > 1 and i < 3: if i > 1 and i < 3:
return i 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