[Python-checkins] python/dist/src/Lib/test test_types.py,1.53,1.54

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Tue, 17 Jun 2003 07:25:16 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv10647

Modified Files:
	test_types.py 
Log Message:
Fix sloppy index() implementation:
- don't use min() and max()
- interpret negative start/stop argument like negative slice indices


Index: test_types.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -d -r1.53 -r1.54
*** test_types.py	17 Jun 2003 05:05:49 -0000	1.53
--- test_types.py	17 Jun 2003 14:25:14 -0000	1.54
***************
*** 365,374 ****
  b.insert(200, "right")
  if b != ["left",-2,-1,0,0,"foo",1,2,"right"]: raise TestFailed, 'list insert2'
  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,3) != 3: raise TestFailed, 'list index, start argument'
  if a.index(0,3,4) != 3: raise TestFailed, 'list index, stop argument'
  try:
      a.index(2,0,-10)
--- 365,378 ----
  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(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)
***************
*** 376,380 ****
      pass
  else:
!     raise TestFailed, 'list index, negative stop argument'
  a.remove(0)
  try:
--- 380,384 ----
      pass
  else:
!     raise TestFailed, 'list index, very -stop argument'
  a.remove(0)
  try: