mirror of
https://github.com/syssec-utd/pylingual.git
synced 2026-05-10 18:39:03 -07:00
Loop test case adjustments
This commit is contained in:
committed by
Joel-Flores123
parent
fbbb3d1c87
commit
b8e0c934fb
+113
-155
@@ -1,15 +1,20 @@
|
||||
# FOR LOOP TESTS
|
||||
|
||||
|
||||
def a_for_over_list():
|
||||
for x in [1, 2, 3]:
|
||||
print("for over list")
|
||||
|
||||
def a1_for_over_list_nofallthru():
|
||||
for x in [1, 2, 3]:
|
||||
print("for over list")
|
||||
print("end")
|
||||
|
||||
def b_for_over_tuples():
|
||||
for a, b in [(1, 2), (3, 4)]:
|
||||
print("tuples")
|
||||
|
||||
def b1_for_over_tuples_nofallthru():
|
||||
for a, b in [(1, 2), (3, 4)]:
|
||||
print("tuples")
|
||||
print("end")
|
||||
|
||||
def c_for_else():
|
||||
for i in range(3):
|
||||
@@ -17,6 +22,12 @@ def c_for_else():
|
||||
else:
|
||||
print("for else")
|
||||
|
||||
def c1_for_else_nofallthru():
|
||||
for i in range(3):
|
||||
print("for body")
|
||||
else:
|
||||
print("for else")
|
||||
print("end")
|
||||
|
||||
def d_for_with_break():
|
||||
for x in range(10):
|
||||
@@ -24,6 +35,12 @@ def d_for_with_break():
|
||||
print("breaking")
|
||||
break
|
||||
|
||||
def d1_for_with_break_nofallthru():
|
||||
for x in range(10):
|
||||
if x == 5:
|
||||
print("breaking")
|
||||
break
|
||||
print("end")
|
||||
|
||||
def e_for_with_continue():
|
||||
for x in range(5):
|
||||
@@ -32,12 +49,24 @@ def e_for_with_continue():
|
||||
continue
|
||||
print("after continue")
|
||||
|
||||
def e1_for_with_continue_nofallthru():
|
||||
for x in range(5):
|
||||
if x % 2 == 0:
|
||||
print("continuing")
|
||||
continue
|
||||
print("after continue")
|
||||
print("end")
|
||||
|
||||
def f_nested_for_loops():
|
||||
for i in range(2):
|
||||
for j in range(3):
|
||||
print(f"nested {i},{j}")
|
||||
|
||||
def f1_nested_for_loops_nofallthru():
|
||||
for i in range(2):
|
||||
for j in range(3):
|
||||
print(f"nested {i},{j}")
|
||||
print("end")
|
||||
|
||||
def g_for_with_try_except():
|
||||
for x in range(2):
|
||||
@@ -46,12 +75,24 @@ def g_for_with_try_except():
|
||||
except Exception:
|
||||
print("except block")
|
||||
|
||||
def g1_for_with_try_except_nofallthru():
|
||||
for x in range(2):
|
||||
try:
|
||||
print("try block")
|
||||
except Exception:
|
||||
print("except block")
|
||||
print("end")
|
||||
|
||||
def h_for_with_with_statement():
|
||||
for _ in range(1):
|
||||
with a:
|
||||
print("inside with")
|
||||
|
||||
def h1_for_with_with_statement_nofallthru():
|
||||
for _ in range(1):
|
||||
with a:
|
||||
print("inside with")
|
||||
print("end")
|
||||
|
||||
def i_for_with_function_call_iterable():
|
||||
def get_items():
|
||||
@@ -60,17 +101,33 @@ def i_for_with_function_call_iterable():
|
||||
for item in get_items():
|
||||
print(f"item: {item}")
|
||||
|
||||
def i1_for_with_function_call_iterable_nofallthru():
|
||||
def get_items():
|
||||
return [1, 2, 3]
|
||||
|
||||
for item in get_items():
|
||||
print(f"item: {item}")
|
||||
print("end")
|
||||
|
||||
def j_for_with_empty_body_ellipsis():
|
||||
for _ in range(3):
|
||||
...
|
||||
|
||||
def j1_for_with_empty_body_ellipsis_nofallthru():
|
||||
for _ in range(3):
|
||||
...
|
||||
print("end")
|
||||
|
||||
def k_while_true_with_break():
|
||||
while True:
|
||||
print("while true")
|
||||
break
|
||||
|
||||
def k1_while_true_with_break_nofallthru():
|
||||
while True:
|
||||
print("while true")
|
||||
break
|
||||
print("end")
|
||||
|
||||
def l_while_with_else():
|
||||
i = 0
|
||||
@@ -80,6 +137,14 @@ def l_while_with_else():
|
||||
else:
|
||||
print("while else")
|
||||
|
||||
def l1_while_with_else_nofallthru():
|
||||
i = 0
|
||||
while i < 3:
|
||||
print(f"looping {i}")
|
||||
i += 1
|
||||
else:
|
||||
print("while else")
|
||||
print("end")
|
||||
|
||||
def m_while_with_continue():
|
||||
i = 0
|
||||
@@ -90,6 +155,15 @@ def m_while_with_continue():
|
||||
continue
|
||||
print("after continue")
|
||||
|
||||
def m1_while_with_continue_nofallthru():
|
||||
i = 0
|
||||
while i < 5:
|
||||
i += 1
|
||||
if i % 2 == 0:
|
||||
print("continue")
|
||||
continue
|
||||
print("after continue")
|
||||
print("end")
|
||||
|
||||
def n_while_with_break():
|
||||
i = 0
|
||||
@@ -97,6 +171,12 @@ def n_while_with_break():
|
||||
print("break in while")
|
||||
break
|
||||
|
||||
def n1_while_with_break_nofallthru():
|
||||
i = 0
|
||||
while True:
|
||||
print("break in while")
|
||||
break
|
||||
print("end")
|
||||
|
||||
def o_nested_while_loops():
|
||||
i = 0
|
||||
@@ -107,151 +187,7 @@ def o_nested_while_loops():
|
||||
j += 1
|
||||
i += 1
|
||||
|
||||
|
||||
def p_while_with_try_except():
|
||||
while True:
|
||||
try:
|
||||
print("try in while")
|
||||
except:
|
||||
print("except in while")
|
||||
|
||||
|
||||
def q_while_with_with_statement():
|
||||
while True:
|
||||
with a:
|
||||
print("inside while with")
|
||||
|
||||
|
||||
def r_for_inside_while():
|
||||
while True:
|
||||
for x in [1, 2]:
|
||||
print("for in while")
|
||||
|
||||
|
||||
def s_while_inside_for():
|
||||
for _ in range(1):
|
||||
while True:
|
||||
print("while in for")
|
||||
break
|
||||
|
||||
|
||||
def t_while_with_empty_body_ellipsis():
|
||||
while True:
|
||||
...
|
||||
|
||||
|
||||
def a_nofallthru_for_over_list():
|
||||
for x in [1, 2, 3]:
|
||||
print("for over list")
|
||||
print("end")
|
||||
|
||||
|
||||
def b_nofallthru_for_over_tuples():
|
||||
for a, b in [(1, 2), (3, 4)]:
|
||||
print("tuples")
|
||||
print("end")
|
||||
|
||||
|
||||
def c_nofallthru_for_else():
|
||||
for i in range(3):
|
||||
print("for body")
|
||||
else:
|
||||
print("for else")
|
||||
print("end")
|
||||
|
||||
|
||||
def d_nofallthru_for_with_break():
|
||||
for x in range(10):
|
||||
if x == 5:
|
||||
print("breaking")
|
||||
break
|
||||
print("end")
|
||||
|
||||
|
||||
def e_nofallthru_for_with_continue():
|
||||
for x in range(5):
|
||||
if x % 2 == 0:
|
||||
print("continuing")
|
||||
continue
|
||||
print("after continue")
|
||||
print("end")
|
||||
|
||||
|
||||
def f_nofallthru_nested_for_loops():
|
||||
for i in range(2):
|
||||
for j in range(3):
|
||||
print(f"nested {i},{j}")
|
||||
print("end")
|
||||
|
||||
|
||||
def g_nofallthru_for_with_try_except():
|
||||
for x in range(2):
|
||||
try:
|
||||
print("try block")
|
||||
except Exception:
|
||||
print("except block")
|
||||
print("end")
|
||||
|
||||
|
||||
def h_nofallthru_for_with_with_statement():
|
||||
for _ in range(1):
|
||||
with a:
|
||||
print("inside with")
|
||||
print("end")
|
||||
|
||||
|
||||
def i_nofallthru_for_with_function_call_iterable():
|
||||
def g_nofallthruet_items():
|
||||
return [1, 2, 3]
|
||||
|
||||
for item in get_items():
|
||||
print(f"item: {item}")
|
||||
print("end")
|
||||
|
||||
|
||||
def j_nofallthru_for_with_empty_body_ellipsis():
|
||||
for _ in range(3):
|
||||
...
|
||||
print("end")
|
||||
|
||||
|
||||
def k_nofallthru_while_true_with_break():
|
||||
while True:
|
||||
print("while true")
|
||||
break
|
||||
print("end")
|
||||
|
||||
|
||||
def l_nofallthru_while_with_else():
|
||||
i = 0
|
||||
while i < 3:
|
||||
print(f"looping {i}")
|
||||
i += 1
|
||||
else:
|
||||
print("while else")
|
||||
print("end")
|
||||
|
||||
|
||||
def m_nofallthru_while_with_continue():
|
||||
i = 0
|
||||
while i < 5:
|
||||
i += 1
|
||||
if i % 2 == 0:
|
||||
print("continue")
|
||||
continue
|
||||
print("after continue")
|
||||
print("end")
|
||||
|
||||
|
||||
def n_nofallthru_while_with_break():
|
||||
i = 0
|
||||
while True:
|
||||
print("break in while")
|
||||
break
|
||||
print("end")
|
||||
|
||||
|
||||
def o_nofallthru_nested_while_loops():
|
||||
def o1_nested_while_loops_nofallthru():
|
||||
i = 0
|
||||
while i < 2:
|
||||
j = 0
|
||||
@@ -261,8 +197,14 @@ def o_nofallthru_nested_while_loops():
|
||||
i += 1
|
||||
print("end")
|
||||
|
||||
def p_while_with_try_except():
|
||||
while True:
|
||||
try:
|
||||
print("try in while")
|
||||
except:
|
||||
print("except in while")
|
||||
|
||||
def p_nofallthru_while_with_try_except():
|
||||
def p1_while_with_try_except_nofallthru():
|
||||
while True:
|
||||
try:
|
||||
print("try in while")
|
||||
@@ -270,30 +212,46 @@ def p_nofallthru_while_with_try_except():
|
||||
print("except in while")
|
||||
print("end")
|
||||
|
||||
def q_while_with_with_statement():
|
||||
while True:
|
||||
with a:
|
||||
print("inside while with")
|
||||
|
||||
def q_nofallthru_while_with_with_statement():
|
||||
def q1_while_with_with_statement_nofallthru():
|
||||
while True:
|
||||
with a:
|
||||
print("inside while with")
|
||||
print("end")
|
||||
|
||||
def r_for_inside_while():
|
||||
while True:
|
||||
for x in [1, 2]:
|
||||
print("for in while")
|
||||
|
||||
def r_nofallthru_for_inside_while():
|
||||
def r1_for_inside_while_nofallthru():
|
||||
while True:
|
||||
for x in [1, 2]:
|
||||
print("for in while")
|
||||
print("end")
|
||||
|
||||
def s_while_inside_for():
|
||||
for _ in range(1):
|
||||
while True:
|
||||
print("while in for")
|
||||
break
|
||||
|
||||
def s_nofallthru_while_inside_for():
|
||||
def s1_while_inside_for_nofallthru():
|
||||
for _ in range(1):
|
||||
while True:
|
||||
print("while in for")
|
||||
break
|
||||
print("end")
|
||||
|
||||
|
||||
def t_nofallthru_while_with_empty_body_ellipsis():
|
||||
def t_while_with_empty_body_ellipsis():
|
||||
while True:
|
||||
...
|
||||
print("end")
|
||||
|
||||
def t1_while_with_empty_body_ellipsis_nofallthru():
|
||||
while True:
|
||||
...
|
||||
print("end")
|
||||
Reference in New Issue
Block a user