-
Notifications
You must be signed in to change notification settings - Fork 167
/
Copy pathtest_for_loop.py
39 lines (30 loc) · 1.07 KB
/
test_for_loop.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from lpython import i32
def test_issue_1153():
start: list[i32] = [-10, 0, 10]
stop: list[i32] = [20, 0, -20]
a: i32; b: i32; c: i32; count: i32; j: i32
for a in range(len(start)):
for b in range(len(stop)):
count = 0
for j in range(start[a], stop[b], -2):
count += 1
assert count == max(0, (start[a] - stop[b]) // 2)
for a in range(len(start)):
for b in range(len(stop)):
count = 0
for j in range(start[a], stop[b], -1):
count += 1
assert count == max(0, start[a] - stop[b])
for a in range(len(start)):
for b in range(len(stop)):
count = 0
for j in range(start[a], stop[b], 2):
count += 1
assert count == max(0, (stop[b] - start[a]) // 2)
for a in range(len(start)):
for b in range(len(stop)):
count = 0
for j in range(start[a], stop[b], 1):
count += 1
assert count == max(0, stop[b] - start[a])
test_issue_1153()