tests/basics/deque2.py: Add tests for deque subscript-from-end.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George 2024-10-30 15:07:58 +11:00
parent 7e1098befe
commit c88a9d60a1

View file

@ -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]