diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-09-12 02:18:30 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-09-12 02:18:30 (GMT) |
commit | 8fa5dd0601ed48c534be96e6f1f3fe54d023d0a0 (patch) | |
tree | 1cbc102532b6b71ed909390912cd806741a0444b /Lib/test | |
parent | ee0fe0b7433a20ab52d033363179d966ef789aef (diff) | |
download | cpython-8fa5dd0601ed48c534be96e6f1f3fe54d023d0a0.zip cpython-8fa5dd0601ed48c534be96e6f1f3fe54d023d0a0.tar.gz cpython-8fa5dd0601ed48c534be96e6f1f3fe54d023d0a0.tar.bz2 |
More bug 460020: lots of string optimizations inhibited for string
subclasses, all "the usual" ones (slicing etc), plus replace, translate,
ljust, rjust, center and strip. I don't know how to be sure they've all
been caught.
Question: Should we complain if someone tries to intern an instance of
a string subclass? I hate to slow any code on those paths.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_descr.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 11a3a5d..a29eb23 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -1481,9 +1481,32 @@ def inherits(): verify(str(s) == "12345") verify(str(s).__class__ is str) - s = madstring("\x00" * 5) - verify(str(s) == "\x00" * 5) + base = "\x00" * 5 + s = madstring(base) + verify(str(s) == base) verify(str(s).__class__ is str) + verify((s + "").__class__ is str) + verify(("" + s).__class__ is str) + verify((s * 0).__class__ is str) + verify((s * 1).__class__ is str) + verify((s * 2).__class__ is str) + verify(s[:].__class__ is str) + verify(s[0:0].__class__ is str) + verify(s.strip().__class__ is str) + identitytab = ''.join([chr(i) for i in range(256)]) + verify(s.translate(identitytab).__class__ is str) + verify(s.translate(identitytab) == base) + verify(s.translate(identitytab, "x").__class__ is str) + verify(s.translate(identitytab, "x") == base) + verify(s.translate(identitytab, "\x00") == "") + verify(s.replace("x", "x").__class__ is str) + verify(s.replace("x", "x") == base) + verify(s.ljust(len(s)).__class__ is str) + verify(s.ljust(len(s)) == base) + verify(s.rjust(len(s)).__class__ is str) + verify(s.rjust(len(s)) == base) + verify(s.center(len(s)).__class__ is str) + verify(s.center(len(s)) == base) class madunicode(unicode): _rev = None |