tests/basics/deque2.py: Add tests for deque subscript-from-end.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
7e1098befe
commit
c88a9d60a1
1 changed files with 10 additions and 0 deletions
|
|
@ -31,6 +31,16 @@ print(d[0], d[1], d[-1])
|
||||||
d[3] = 5
|
d[3] = 5
|
||||||
print(d[3])
|
print(d[3])
|
||||||
|
|
||||||
|
# Access the last element via index, when the last element is at various locations
|
||||||
|
d = deque((), 2)
|
||||||
|
for i in range(4):
|
||||||
|
d.append(i)
|
||||||
|
print(i, d[-1])
|
||||||
|
|
||||||
|
# Write the last element then access all elements from the end
|
||||||
|
d[-1] = 4
|
||||||
|
print(d[-2], d[-1])
|
||||||
|
|
||||||
# Accessing indices out of bounds raises IndexError
|
# Accessing indices out of bounds raises IndexError
|
||||||
try:
|
try:
|
||||||
d[4]
|
d[4]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue