mirror of
https://github.com/python/cpython
synced 2024-10-17 15:28:20 +00:00
173f11da5d
/* this is harder to get right than you might think */ angered some God somewhere. After noticing >>> range(5000000)[slice(96360, None, 439)] [] I found that my cute test for the slice being empty failed due to overflow. Fixed, and added simple test (not the above!).
17 lines
680 B
Python
17 lines
680 B
Python
# tests for slice objects; in particular the indices method.
|
|
|
|
from test.test_support import vereq
|
|
import sys
|
|
|
|
vereq(slice(None ).indices(10), (0, 10, 1))
|
|
vereq(slice(None, None, 2).indices(10), (0, 10, 2))
|
|
vereq(slice(1, None, 2).indices(10), (1, 10, 2))
|
|
vereq(slice(None, None, -1).indices(10), (9, -1, -1))
|
|
vereq(slice(None, None, -2).indices(10), (9, -1, -2))
|
|
vereq(slice(3, None, -2).indices(10), (3, -1, -2))
|
|
vereq(slice(-100, 100 ).indices(10), slice(None).indices(10))
|
|
vereq(slice(100, -100, -1).indices(10), slice(None, None, -1).indices(10))
|
|
vereq(slice(-100L, 100L, 2L).indices(10), (0, 10, 2))
|
|
|
|
vereq(range(10)[::sys.maxint - 1], [0])
|