circuitpython/tests/basics/list_slice.py
Damien George b5186c9271 tests/basics: Split out specific slice tests to separate files.
So they can be automatically skipped if slice is not enabled.
2019-10-29 22:22:37 +11:00

34 lines
424 B
Python

# test list slices, getting values
x = list(range(10))
print(x[1:])
print(x[:-1])
print(x[2:3])
a = 2
b = 4
c = 3
print(x[:])
print(x[::])
print(x[::c])
print(x[:b])
print(x[:b:])
print(x[:b:c])
print(x[a])
print(x[a:])
print(x[a::])
print(x[a::c])
print(x[a:b])
print(x[a:b:])
print(x[a:b:c])
# these should not raise IndexError
print([][1:])
print([][-1:])
try:
[][::0]
except ValueError:
print('ValueError')