mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Fix PR#7 comparisons of recursive objects
Note that comparisons of deeply nested objects can still dump core in extreme cases.
This commit is contained in:
parent
0556501a81
commit
4a3dd2dcc2
4 changed files with 126 additions and 3 deletions
|
@ -63,6 +63,15 @@ print 'cmp'
|
|||
if cmp(-1, 1) <> -1: raise TestFailed, 'cmp(-1, 1)'
|
||||
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'
|
||||
if fcmp(coerce(1, 1.1), (1.0, 1.1)): raise TestFailed, 'coerce(1, 1.1)'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue