summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2003-06-17 14:25:14 (GMT)
committerGuido van Rossum <guido@python.org>2003-06-17 14:25:14 (GMT)
commit2743d87d7934535f16a0ea062a28c21ea18e5a24 (patch)
treea900db61838c03a5371be0edb71895078fc17e15 /Lib
parent77cdeaff556447a980fe8632e8cd010499ade2d0 (diff)
downloadcpython-2743d87d7934535f16a0ea062a28c21ea18e5a24.zip
cpython-2743d87d7934535f16a0ea062a28c21ea18e5a24.tar.gz
cpython-2743d87d7934535f16a0ea062a28c21ea18e5a24.tar.bz2
Fix sloppy index() implementation:
- don't use min() and max() - interpret negative start/stop argument like negative slice indices
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_types.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py
index 9599456..61f660b 100644
--- a/Lib/test/test_types.py
+++ b/Lib/test/test_types.py
@@ -364,18 +364,22 @@ b.insert(-2, "foo")
b.insert(-200, "left")
b.insert(200, "right")
if b != ["left",-2,-1,0,0,"foo",1,2,"right"]: raise TestFailed, 'list insert2'
+# a = [-2,-1,0,0,1,2]
if a.count(0) != 2: raise TestFailed, ' list count'
if a.index(0) != 2: raise TestFailed, 'list index'
if a.index(0,2) != 2: raise TestFailed, 'list index, start argument'
-if a.index(-2,-10) != 0: raise TestFailed, 'list index, negative start argument'
+if a.index(0,-4) != 2: raise TestFailed, 'list index, -start argument'
+if a.index(-2,-10) != 0: raise TestFailed, 'list index, very -start argument'
if a.index(0,3) != 3: raise TestFailed, 'list index, start argument'
+if a.index(0,-3) != 3: raise TestFailed, 'list index, -start argument'
if a.index(0,3,4) != 3: raise TestFailed, 'list index, stop argument'
+if a.index(0,-3,-2) != 3: raise TestFailed, 'list index, -stop argument'
try:
a.index(2,0,-10)
except ValueError:
pass
else:
- raise TestFailed, 'list index, negative stop argument'
+ raise TestFailed, 'list index, very -stop argument'
a.remove(0)
try:
a.index(2,0,4)