tests/basics: Add tests for raising ValueError when range() gets 0 step.

This commit is contained in:
Damien George 2017-04-05 10:52:29 +10:00
parent de9b53695d
commit dcd8f52766
2 changed files with 13 additions and 0 deletions

View File

@ -34,6 +34,12 @@ print(range(1, 4)[1:])
print(range(1, 4)[:-1])
print(range(7, -2, -4)[:])
# zero step
try:
range(1, 2, 0)
except ValueError:
print("ValueError")
# bad unary op
try:
-range(1)

View File

@ -6,6 +6,13 @@ for x in range(*(1, 3)):
for x in range(1, *(6, 2)):
print(x)
# zero step
try:
for x in range(1, 2, 0):
pass
except ValueError:
print('ValueError')
# apply args using **
try:
for x in range(**{'end':1}):