summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_b1.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-11-27 22:53:50 (GMT)
committerGuido van Rossum <guido@python.org>1992-11-27 22:53:50 (GMT)
commit85f1820ee15faec7961056ace378f2d444419c1c (patch)
tree41ccba707377e7df1229b0dd8806217dee497fbc /Lib/test/test_b1.py
parentd014ea6b5efbfb3d143fc8aacf8bee733cf4c8f0 (diff)
downloadcpython-85f1820ee15faec7961056ace378f2d444419c1c.zip
cpython-85f1820ee15faec7961056ace378f2d444419c1c.tar.gz
cpython-85f1820ee15faec7961056ace378f2d444419c1c.tar.bz2
Added some new tests and two new files for testing: test_types.py
(testing operations on built-in types) and autotest.py (automatic regression testing).
Diffstat (limited to 'Lib/test/test_b1.py')
-rw-r--r--Lib/test/test_b1.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_b1.py b/Lib/test/test_b1.py
index 1fafc4f..b780c72 100644
--- a/Lib/test/test_b1.py
+++ b/Lib/test/test_b1.py
@@ -36,6 +36,16 @@ if chr(32) <> ' ': raise TestFailed, 'chr(32)'
if chr(65) <> 'A': raise TestFailed, 'chr(65)'
if chr(97) <> 'a': raise TestFailed, 'chr(97)'
+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)'
+
+print 'coerce'
+if coerce(1, 1.1) <> (1.0, 1.1): raise TestFailed, 'coerce(1, 1.1)'
+if coerce(1, 1L) <> (1L, 1L): raise TestFailed, 'coerce(1, 1L)'
+if coerce(1L, 1.1) <> (1.0, 1.1): raise TestFailed, 'coerce(1L, 1.1)'
+
print 'dir'
x = 1
if 'x' not in dir(): raise TestFailed, 'dir()'
@@ -65,11 +75,24 @@ if divmod(-3.25, -1.0) <> (3.0, -0.25): raise TestFailed, 'divmod(-3.25, -1.0)'
print 'eval'
if eval('1+1') <> 2: raise TestFailed, 'eval(\'1+1\')'
+if eval(' 1+1\n') <> 2: raise TestFailed, 'eval(\' 1+1\\n\')'
print 'exec'
z = 0
exec('z=1+1\n')
if z <> 2: raise TestFailed, 'exec(\'z=1+1\'\\n)'
+z = 0
+exec('z=1+1')
+if z <> 2: raise TestFailed, 'exec(\'z=1+1\')'
+
+print 'execfile'
+z = 0
+f = open(TESTFN, 'w')
+f.write('z = z+1\n')
+f.write('z = z*2\n')
+f.close()
+execfile(TESTFN)
+unlink(TESTFN)
print 'float'
if float(3.14) <> 3.14: raise TestFailed, 'float(3.14)'