[Python-checkins] CVS: python/dist/src/Lib/test test_b1.py,1.21,1.22

Jeremy Hylton python-dev@python.org
Fri, 14 Apr 2000 15:13:25 -0400 (EDT)


Update of /projects/cvsroot/python/dist/src/Lib/test
In directory bitdiddle:/home/jhylton/python/src/Lib/test

Modified Files:
	test_b1.py 
Log Message:
Fix PR#7 comparisons of recursive objects

Note that comparisons of deeply nested objects can still dump core in
extreme cases.


Index: test_b1.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/test/test_b1.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -r1.21 -r1.22
*** test_b1.py	2000/04/05 20:11:19	1.21
--- test_b1.py	2000/04/14 19:13:22	1.22
***************
*** 64,67 ****
--- 64,76 ----
  if cmp(1, -1) <> 1: raise TestFailed, 'cmp(1, -1)'
  if cmp(1, 1) <> 0: raise TestFailed, 'cmp(1, 1)'
+ # verify that circular objects are handled
+ a = []; a.append(a)
+ b = []; b.append(b)
+ from UserList import UserList
+ c = UserList(); c.append(c)
+ if cmp(a, b) != 0: raise TestFailed, "cmp(%s, %s)" % (a, b)
+ if cmp(b, c) != 0: raise TestFailed, "cmp(%s, %s)" % (b, c)
+ if cmp(c, a) != 0: raise TestFailed, "cmp(%s, %s)" % (c, a)
+ if cmp(a, c) != 0: raise TestFailed, "cmp(%s, %s)" % (a, c)
  
  print 'coerce'