diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2000-04-14 19:13:24 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2000-04-14 19:13:24 (GMT) |
commit | 4a3dd2dcc2fae12b6736822731848c557b80d0e3 (patch) | |
tree | 14c6c5f32289f00d0328daff5a23ea50c06f23e0 /Lib/test/test_b1.py | |
parent | 0556501a810467fcb18f0a0f312b475dff27d20b (diff) | |
download | cpython-4a3dd2dcc2fae12b6736822731848c557b80d0e3.zip cpython-4a3dd2dcc2fae12b6736822731848c557b80d0e3.tar.gz cpython-4a3dd2dcc2fae12b6736822731848c557b80d0e3.tar.bz2 |
Fix PR#7 comparisons of recursive objects
Note that comparisons of deeply nested objects can still dump core in
extreme cases.
Diffstat (limited to 'Lib/test/test_b1.py')
-rw-r--r-- | Lib/test/test_b1.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_b1.py b/Lib/test/test_b1.py index 6a89d22..b063e5a 100644 --- a/Lib/test/test_b1.py +++ b/Lib/test/test_b1.py @@ -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)' |