Commit 0a1e62d9 authored by Robert Bradshaw's avatar Robert Bradshaw

loop semantics are STILL wrong, as were some T203 doctests

--HG--
extra : transplant_source : %E1%9D%DB%8B%E0%1D%C3%AEMD%7Cn%AA%D95%16%D9%085%9C
parent 2f08050b
__doc__ = u""" __doc__ = u"""
>>> test_var(10, 5) >>> for_from_range(5, 10)
range(5)
at 0
at 1
at 2
at 3
at 4
range(5, 10)
at 5
at 6
at 7
at 8
at 9
range(5, 10, 2)
at 5
at 7
at 9
9
>>> for_from_bound_reassignment(5, 1)
at 0 at 0
at 1 at 1
at 2 at 2
at 3 at 3
at 4 at 4
5 5
>>> for_from_step_reassignment(15, 5, 2)
at 0
at 5
at 10
15
>>> for_from_target_reassignment(10, 2)
at 0
at 1
at 3
at 7
15
>>> for_from_py_target_reassignment(10, 2)
at 0
at 1
at 3
at 7
15
>>> for_in_target_reassignment(10, 2)
at 0
at 1
at 2
at 3
at 4
at 5
at 6
at 7
at 8
at 9
18
>>> test_func(5) >>> test_func(5)
get_bound(5) get_bound(5)
at 0 at 0
...@@ -14,47 +61,61 @@ at 2 ...@@ -14,47 +61,61 @@ at 2
at 3 at 3
at 4 at 4
5 5
>>> test_f()
9
>>> f()
g called
0
1
2
2
""" """
def for_from_range(a, b):
cdef int i
print "range(%s)" % a
for i in range(a):
print "at", i
print "range(%s, %s)" % (a, b)
for i in range(a, b):
print "at", i
print "range(%s, %s, %s)" % (a, b, 2)
for i in range(a, b, 2):
print "at", i
return i
cdef int get_bound(int m): cdef int get_bound(int m):
print "get_bound(%s)"%m print "get_bound(%s)"%m
return m return m
def test_var(int n, int m): def for_from_bound_reassignment(int bound, int fake_bound):
cdef int i cdef int i
for i from 0 <= i < n: for i from 0 <= i < bound:
print "at", i print "at", i
n = m bound = fake_bound
return i return i
def test_func(int n): def for_from_step_reassignment(int bound, int step, int fake_step):
cdef int i cdef int i
for i from 0 <= i < get_bound(n): for i from 0 <= i < bound by step:
print "at", i print "at", i
step = fake_step
return i return i
def test_f(): def for_from_target_reassignment(int bound, int factor):
cdef int i,n cdef int i
n = 10 for i from 0 <= i < bound:
for i in range(n): print "at", i
if i == 5: n *= 2 i *= factor
print i return i
cdef int g(): def for_from_py_target_reassignment(int bound, int factor):
print "g called" cdef object i
return 3 for i from 0 <= i < bound:
print "at", i
i *= factor
return i
def f(): def for_in_target_reassignment(int bound, int factor):
cdef int i = -1 cdef int i
for i in range(g()): for i in range(bound):
print i print "at", i
print i i *= factor
return i
def test_func(int n):
cdef int i
for i from 0 <= i < get_bound(n):
print "at", i
return i
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