summaryrefslogtreecommitdiffstats
path: root/Lib/dos-8x3/test_str.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-04-02 06:13:34 (GMT)
committerGuido van Rossum <guido@python.org>1997-04-02 06:13:34 (GMT)
commit228b8e88bc7a7ce740e5c7326697e7c2256e099f (patch)
tree81149f4696131ea3d2c123fb169c8a31db23a76a /Lib/dos-8x3/test_str.py
parentd69a84b01eb802b2bfd7dd2c868a9b2da9465a5e (diff)
downloadcpython-228b8e88bc7a7ce740e5c7326697e7c2256e099f.zip
cpython-228b8e88bc7a7ce740e5c7326697e7c2256e099f.tar.gz
cpython-228b8e88bc7a7ce740e5c7326697e7c2256e099f.tar.bz2
Whole lotta changes.
Diffstat (limited to 'Lib/dos-8x3/test_str.py')
-rw-r--r--Lib/dos-8x3/test_str.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/Lib/dos-8x3/test_str.py b/Lib/dos-8x3/test_str.py
index 424cf52..efc98ff 100644
--- a/Lib/dos-8x3/test_str.py
+++ b/Lib/dos-8x3/test_str.py
@@ -1,13 +1,21 @@
+from test_support import verbose
import strop, sys
def test(name, input, output, *args):
+ if verbose:
+ print 'string.%s%s =? %s... ' % (name, (input,) + args, output),
f = getattr(strop, name)
try:
value = apply(f, (input,) + args)
except:
value = sys.exc_type
if value != output:
+ if verbose:
+ print 'no'
print f, `input`, `output`, `value`
+ else:
+ if verbose:
+ print 'yes'
test('atoi', " 1 ", 1)
test('atoi', " 1x", ValueError)
@@ -38,8 +46,19 @@ test('split', 'this is the split function',
test('split', 'a|b|c|d', ['a', 'b', 'c', 'd'], '|')
test('split', 'a|b|c|d', ['a', 'b', 'c|d'], '|', 2)
+# join now works with any sequence type
+class Sequence:
+ def __init__(self): self.seq = 'wxyz'
+ def __len__(self): return len(self.seq)
+ def __getitem__(self, i): return self.seq[i]
+
test('join', ['a', 'b', 'c', 'd'], 'a b c d')
-test('join', ['a', 'b', 'c', 'd'], 'abcd', '')
+test('join', ('a', 'b', 'c', 'd'), 'abcd', '')
+test('join', Sequence(), 'w x y z')
+
+# try a few long ones
+print strop.join(['x' * 100] * 100, ':')
+print strop.join(('x' * 100,) * 100, ':')
test('strip', ' hello ', 'hello')
test('lstrip', ' hello ', 'hello ')