home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / MacHacksBug / Python 1.5.2c1 / Lib / test / test_b1.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-06-23  |  20.3 KB  |  926 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. *
  5. print '__import__'
  6. __import__('sys')
  7. __import__('strop')
  8. __import__('string')
  9.  
  10. try:
  11.     __import__('spamspam')
  12. except ImportError:
  13.     pass
  14.  
  15. raise TestFailed, "__import__('spamspam') should fail"
  16. print 'abs'
  17. if abs(0) != 0:
  18.     raise TestFailed, 'abs(0)'
  19.  
  20. if abs(1234) != 1234:
  21.     raise TestFailed, 'abs(1234)'
  22.  
  23. if abs(-1234) != 1234:
  24.     raise TestFailed, 'abs(-1234)'
  25.  
  26. if abs(0.0) != 0.0:
  27.     raise TestFailed, 'abs(0.0)'
  28.  
  29. if abs(3.14) != 3.14:
  30.     raise TestFailed, 'abs(3.14)'
  31.  
  32. if abs(-3.14) != 3.14:
  33.     raise TestFailed, 'abs(-3.14)'
  34.  
  35. if abs(0x0L) != 0x0L:
  36.     raise TestFailed, 'abs(0L)'
  37.  
  38. if abs(0x4D2L) != 0x4D2L:
  39.     raise TestFailed, 'abs(1234L)'
  40.  
  41. if abs(-0x4D2L) != 0x4D2L:
  42.     raise TestFailed, 'abs(-1234L)'
  43.  
  44. print 'apply'
  45.  
  46. def f0(*args):
  47.     if args != ():
  48.         raise TestFailed, 'f0 called with ' + `args`
  49.     
  50.  
  51.  
  52. def f1(a1):
  53.     if a1 != 1:
  54.         raise TestFailed, 'f1 called with ' + `a1`
  55.     
  56.  
  57.  
  58. def f2(a1, a2):
  59.     if a1 != 1 or a2 != 2:
  60.         raise TestFailed, 'f2 called with ' + `(a1, a2)`
  61.     
  62.  
  63.  
  64. def f3(a1, a2, a3):
  65.     if a1 != 1 and a2 != 2 or a3 != 3:
  66.         raise TestFailed, 'f3 called with ' + `(a1, a2, a3)`
  67.     
  68.  
  69. apply(f0, ())
  70. apply(f1, (1,))
  71. apply(f2, (1, 2))
  72. apply(f3, (1, 2, 3))
  73. print 'callable'
  74. if not callable(len):
  75.     raise TestFailed, 'callable(len)'
  76.  
  77.  
  78. def f():
  79.     pass
  80.  
  81. if not callable(f):
  82.     raise TestFailed, 'callable(f)'
  83.  
  84.  
  85. class C:
  86.     
  87.     def meth(self):
  88.         pass
  89.  
  90.  
  91. if not callable(C):
  92.     raise TestFailed, 'callable(C)'
  93.  
  94. x = C()
  95. if not callable(x.meth):
  96.     raise TestFailed, 'callable(x.meth)'
  97.  
  98. if callable(x):
  99.     raise TestFailed, 'callable(x)'
  100.  
  101.  
  102. class D(C):
  103.     
  104.     def __call__(self):
  105.         pass
  106.  
  107.  
  108. y = D()
  109. if not callable(y):
  110.     raise TestFailed, 'callable(y)'
  111.  
  112. print 'chr'
  113. if chr(32) != ' ':
  114.     raise TestFailed, 'chr(32)'
  115.  
  116. if chr(65) != 'A':
  117.     raise TestFailed, 'chr(65)'
  118.  
  119. if chr(97) != 'a':
  120.     raise TestFailed, 'chr(97)'
  121.  
  122. print 'cmp'
  123. if cmp(-1, 1) != -1:
  124.     raise TestFailed, 'cmp(-1, 1)'
  125.  
  126. if cmp(1, -1) != 1:
  127.     raise TestFailed, 'cmp(1, -1)'
  128.  
  129. if cmp(1, 1) != 0:
  130.     raise TestFailed, 'cmp(1, 1)'
  131.  
  132. print 'coerce'
  133. if fcmp(coerce(1, 1.1), (1.0, 1.1)):
  134.     raise TestFailed, 'coerce(1, 1.1)'
  135.  
  136. if coerce(1, 0x1L) != (0x1L, 0x1L):
  137.     raise TestFailed, 'coerce(1, 1L)'
  138.  
  139. if fcmp(coerce(0x1L, 1.1), (1.0, 1.1)):
  140.     raise TestFailed, 'coerce(1L, 1.1)'
  141.  
  142. print 'compile'
  143. compile('print 1\n', '', 'exec')
  144. print 'complex'
  145. if complex(1, 10) != 1 + (0.0+10.0j):
  146.     raise TestFailed, 'complex(1,10)'
  147.  
  148. if complex(1, 0xAL) != 1 + (0.0+10.0j):
  149.     raise TestFailed, 'complex(1,10L)'
  150.  
  151. if complex(1, 10.0) != 1 + (0.0+10.0j):
  152.     raise TestFailed, 'complex(1,10.0)'
  153.  
  154. if complex(0x1L, 10) != 1 + (0.0+10.0j):
  155.     raise TestFailed, 'complex(1L,10)'
  156.  
  157. if complex(0x1L, 0xAL) != 1 + (0.0+10.0j):
  158.     raise TestFailed, 'complex(1L,10L)'
  159.  
  160. if complex(0x1L, 10.0) != 1 + (0.0+10.0j):
  161.     raise TestFailed, 'complex(1L,10.0)'
  162.  
  163. if complex(1.0, 10) != 1 + (0.0+10.0j):
  164.     raise TestFailed, 'complex(1.0,10)'
  165.  
  166. if complex(1.0, 0xAL) != 1 + (0.0+10.0j):
  167.     raise TestFailed, 'complex(1.0,10L)'
  168.  
  169. if complex(1.0, 10.0) != 1 + (0.0+10.0j):
  170.     raise TestFailed, 'complex(1.0,10.0)'
  171.  
  172. if complex(3.14 + (0.0+0.0j)) != 3.14 + (0.0+0.0j):
  173.     raise TestFailed, 'complex(3.14)'
  174.  
  175. if complex(3.14) != 3.14 + (0.0+0.0j):
  176.     raise TestFailed, 'complex(3.14)'
  177.  
  178. if complex(314) != 314.0 + (0.0+0.0j):
  179.     raise TestFailed, 'complex(314)'
  180.  
  181. if complex(0x13AL) != 314.0 + (0.0+0.0j):
  182.     raise TestFailed, 'complex(314L)'
  183.  
  184. if complex(3.14 + (0.0+0.0j), (0.0+0.0j)) != 3.14 + (0.0+0.0j):
  185.     raise TestFailed, 'complex(3.14, 0j)'
  186.  
  187. if complex(3.14, 0.0) != 3.14 + (0.0+0.0j):
  188.     raise TestFailed, 'complex(3.14, 0.0)'
  189.  
  190. if complex(314, 0) != 314.0 + (0.0+0.0j):
  191.     raise TestFailed, 'complex(314, 0)'
  192.  
  193. if complex(0x13AL, 0x0L) != 314.0 + (0.0+0.0j):
  194.     raise TestFailed, 'complex(314L, 0L)'
  195.  
  196. if complex((0.0+0.0j), (0.0+3.14j)) != -3.14 + (0.0+0.0j):
  197.     raise TestFailed, 'complex(0j, 3.14j)'
  198.  
  199. if complex(0.0, (0.0+3.14j)) != -3.14 + (0.0+0.0j):
  200.     raise TestFailed, 'complex(0.0, 3.14j)'
  201.  
  202. if complex((0.0+0.0j), 3.14) != (0.0+3.14j):
  203.     raise TestFailed, 'complex(0j, 3.14)'
  204.  
  205. if complex(0.0, 3.14) != (0.0+3.14j):
  206.     raise TestFailed, 'complex(0.0, 3.14)'
  207.  
  208. if complex('  3.14+J  ') != 3.14 + (0.0+1.0j):
  209.     raise TestFailed, 'complex("  3.14+J  )"'
  210.  
  211.  
  212. class Z:
  213.     
  214.     def __complex__(self):
  215.         return (0.0+3.14j)
  216.  
  217.  
  218. z = Z()
  219. if complex(z) != (0.0+3.14j):
  220.     raise TestFailed, 'complex(classinstance)'
  221.  
  222. print 'delattr'
  223. import sys
  224. sys.spam = 1
  225. delattr(sys, 'spam')
  226. print 'dir'
  227. x = 1
  228. if 'x' not in dir():
  229.     raise TestFailed, 'dir()'
  230.  
  231. import sys
  232. if 'modules' not in dir(sys):
  233.     raise TestFailed, 'dir(sys)'
  234.  
  235. print 'divmod'
  236. if divmod(12, 7) != (1, 5):
  237.     raise TestFailed, 'divmod(12, 7)'
  238.  
  239. if divmod(-12, 7) != (-2, 2):
  240.     raise TestFailed, 'divmod(-12, 7)'
  241.  
  242. if divmod(12, -7) != (-2, -2):
  243.     raise TestFailed, 'divmod(12, -7)'
  244.  
  245. if divmod(-12, -7) != (1, -5):
  246.     raise TestFailed, 'divmod(-12, -7)'
  247.  
  248. if divmod(0xCL, 0x7L) != (0x1L, 0x5L):
  249.     raise TestFailed, 'divmod(12L, 7L)'
  250.  
  251. if divmod(-0xCL, 0x7L) != (-0x2L, 0x2L):
  252.     raise TestFailed, 'divmod(-12L, 7L)'
  253.  
  254. if divmod(0xCL, -0x7L) != (-0x2L, -0x2L):
  255.     raise TestFailed, 'divmod(12L, -7L)'
  256.  
  257. if divmod(-0xCL, -0x7L) != (0x1L, -0x5L):
  258.     raise TestFailed, 'divmod(-12L, -7L)'
  259.  
  260. if divmod(12, 0x7L) != (1, 0x5L):
  261.     raise TestFailed, 'divmod(12, 7L)'
  262.  
  263. if divmod(-12, 0x7L) != (-2, 0x2L):
  264.     raise TestFailed, 'divmod(-12, 7L)'
  265.  
  266. if divmod(0xCL, -7) != (-0x2L, -2):
  267.     raise TestFailed, 'divmod(12L, -7)'
  268.  
  269. if divmod(-0xCL, -7) != (0x1L, -5):
  270.     raise TestFailed, 'divmod(-12L, -7)'
  271.  
  272. if fcmp(divmod(3.25, 1.0), (3.0, 0.25)):
  273.     raise TestFailed, 'divmod(3.25, 1.0)'
  274.  
  275. if fcmp(divmod(-3.25, 1.0), (-4.0, 0.75)):
  276.     raise TestFailed, 'divmod(-3.25, 1.0)'
  277.  
  278. if fcmp(divmod(3.25, -1.0), (-4.0, -0.75)):
  279.     raise TestFailed, 'divmod(3.25, -1.0)'
  280.  
  281. if fcmp(divmod(-3.25, -1.0), (3.0, -0.25)):
  282.     raise TestFailed, 'divmod(-3.25, -1.0)'
  283.  
  284. print 'eval'
  285. if eval('1+1') != 2:
  286.     raise TestFailed, "eval('1+1')"
  287.  
  288. if eval(' 1+1\n') != 2:
  289.     raise TestFailed, "eval(' 1+1\\n')"
  290.  
  291. globals = {
  292.     'a': 1,
  293.     'b': 2 }
  294. locals = {
  295.     'b': 200,
  296.     'c': 300 }
  297. if eval('a', globals) != 1:
  298.     raise TestFailed, 'eval(1)'
  299.  
  300. if eval('a', globals, locals) != 1:
  301.     raise TestFailed, 'eval(2)'
  302.  
  303. if eval('b', globals, locals) != 200:
  304.     raise TestFailed, 'eval(3)'
  305.  
  306. if eval('c', globals, locals) != 300:
  307.     raise TestFailed, 'eval(4)'
  308.  
  309. print 'execfile'
  310. z = 0
  311. f = open(TESTFN, 'w')
  312. f.write('z = z+1\n')
  313. f.write('z = z*2\n')
  314. f.close()
  315. execfile(TESTFN)
  316. if z != 2:
  317.     raise TestFailed, 'execfile(1)'
  318.  
  319. globals['z'] = 0
  320. execfile(TESTFN, globals)
  321. if globals['z'] != 2:
  322.     raise TestFailed, 'execfile(1)'
  323.  
  324. locals['z'] = 0
  325. execfile(TESTFN, globals, locals)
  326. if locals['z'] != 2:
  327.     raise TestFailed, 'execfile(1)'
  328.  
  329. unlink(TESTFN)
  330. print 'filter'
  331. if filter((lambda c: None if c <= c else c <= 'z'), 'Hello World') != 'elloorld':
  332.     raise TestFailed, 'filter (filter a string)'
  333.  
  334. if filter(None, [
  335.     1,
  336.     'hello',
  337.     [],
  338.     [
  339.         3],
  340.     '',
  341.     None,
  342.     9,
  343.     0]) != [
  344.     1,
  345.     'hello',
  346.     [
  347.         3],
  348.     9]:
  349.     raise TestFailed, 'filter (remove false values)'
  350.  
  351. if filter((lambda x: x > 0), [
  352.     1,
  353.     -3,
  354.     9,
  355.     0,
  356.     2]) != [
  357.     1,
  358.     9,
  359.     2]:
  360.     raise TestFailed, 'filter (keep positives)'
  361.  
  362.  
  363. class Squares:
  364.     
  365.     def __init__(self, max):
  366.         self.max = max
  367.         self.sofar = []
  368.  
  369.     
  370.     def __len__(self):
  371.         return len(self.sofar)
  372.  
  373.     
  374.     def __getitem__(self, i):
  375.         if not None if i <= i else i < self.max:
  376.             raise IndexError
  377.         
  378.         n = len(self.sofar)
  379.         while n <= i:
  380.             self.sofar.append(n * n)
  381.             n = n + 1
  382.         return self.sofar[i]
  383.  
  384.  
  385. if filter(None, Squares(10)) != [
  386.     1,
  387.     4,
  388.     9,
  389.     16,
  390.     25,
  391.     36,
  392.     49,
  393.     64,
  394.     81]:
  395.     raise TestFailed, 'filter(None, Squares(10))'
  396.  
  397. if filter((lambda x: x % 2), Squares(10)) != [
  398.     1,
  399.     9,
  400.     25,
  401.     49,
  402.     81]:
  403.     raise TestFailed, 'filter(oddp, Squares(10))'
  404.  
  405.  
  406. class StrSquares:
  407.     
  408.     def __init__(self, max):
  409.         self.max = max
  410.         self.sofar = []
  411.  
  412.     
  413.     def __len__(self):
  414.         return len(self.sofar)
  415.  
  416.     
  417.     def __getitem__(self, i):
  418.         if not None if i <= i else i < self.max:
  419.             raise IndexError
  420.         
  421.         n = len(self.sofar)
  422.         while n <= i:
  423.             self.sofar.append(str(n * n))
  424.             n = n + 1
  425.         return self.sofar[i]
  426.  
  427.  
  428.  
  429. def identity(item):
  430.     return 1
  431.  
  432. filter(identity, Squares(5))
  433. print 'float'
  434. if float(3.14) != 3.14:
  435.     raise TestFailed, 'float(3.14)'
  436.  
  437. if float(314) != 314.0:
  438.     raise TestFailed, 'float(314)'
  439.  
  440. if float(0x13AL) != 314.0:
  441.     raise TestFailed, 'float(314L)'
  442.  
  443. if float('  3.14  ') != 3.14:
  444.     raise TestFailed, 'float("  3.14  ")'
  445.  
  446. print 'getattr'
  447. import sys
  448. if getattr(sys, 'stdout') is not sys.stdout:
  449.     raise TestFailed, 'getattr'
  450.  
  451. print 'hasattr'
  452. import sys
  453. if not hasattr(sys, 'stdout'):
  454.     raise TestFailed, 'hasattr'
  455.  
  456. print 'hash'
  457. hash(None)
  458. if not None if hash(0x1L) == hash(0x1L) else hash(0x1L) == hash(1.0):
  459.     raise TestFailed, 'numeric hash()'
  460.  
  461. hash('spam')
  462. hash((0, 1, 2, 3))
  463.  
  464. def f():
  465.     pass
  466.  
  467. print 'hex'
  468. if hex(16) != '0x10':
  469.     raise TestFailed, 'hex(16)'
  470.  
  471. if hex(0x10L) != '0x10L':
  472.     raise TestFailed, 'hex(16L)'
  473.  
  474. if len(hex(-1)) != len(hex(sys.maxint)):
  475.     raise TestFailed, 'len(hex(-1))'
  476.  
  477. if hex(-16) not in ('0xfffffff0', '0xfffffffffffffff0'):
  478.     raise TestFailed, 'hex(-16)'
  479.  
  480. if hex(-0x10L) != '-0x10L':
  481.     raise TestFailed, 'hex(-16L)'
  482.  
  483. print 'id'
  484. id(None)
  485. id(1)
  486. id(0x1L)
  487. id(1.0)
  488. id('spam')
  489. id((0, 1, 2, 3))
  490. id([
  491.     0,
  492.     1,
  493.     2,
  494.     3])
  495. id({
  496.     'spam': 1,
  497.     'eggs': 2,
  498.     'ham': 3 })
  499. print 'int'
  500. if int(314) != 314:
  501.     raise TestFailed, 'int(314)'
  502.  
  503. if int(3.14) != 3:
  504.     raise TestFailed, 'int(3.14)'
  505.  
  506. if int(0x13AL) != 314:
  507.     raise TestFailed, 'int(314L)'
  508.  
  509. if int(-3.14) != -3:
  510.     raise TestFailed, 'int(-3.14)'
  511.  
  512. if int(3.9) != 3:
  513.     raise TestFailed, 'int(3.9)'
  514.  
  515. if int(-3.9) != -3:
  516.     raise TestFailed, 'int(-3.9)'
  517.  
  518. if int(3.5) != 3:
  519.     raise TestFailed, 'int(3.5)'
  520.  
  521. if int(-3.5) != -3:
  522.     raise TestFailed, 'int(-3.5)'
  523.  
  524. L = [
  525.     ('0', 0),
  526.     ('1', 1),
  527.     ('9', 9),
  528.     ('10', 10),
  529.     ('99', 99),
  530.     ('100', 100),
  531.     ('314', 314),
  532.     (' 314', 314),
  533.     ('314 ', 314),
  534.     ('  \t\t  314  \t\t  ', 314),
  535.     (`sys.maxint`, sys.maxint),
  536.     ('', ValueError),
  537.     (' ', ValueError),
  538.     ('  \t\t  ', ValueError)]
  539. for s, v in L:
  540.     for sign in ('', '+', '-'):
  541.         for prefix in ('', ' ', '\t', '  \t\t  '):
  542.             ss = prefix + sign + s
  543.             vv = v
  544.             
  545.             try:
  546.                 if int(ss) != vv:
  547.                     raise TestFailed, 'int(%s)' % `ss`
  548.             except v:
  549.                 0 if sign == '-' and v is not ValueError else ('', ' ', '\t', '  \t\t  ')
  550.                 0 if sign == '-' and v is not ValueError else ('', ' ', '\t', '  \t\t  ')
  551.                 ('', '+', '-')
  552.             except ValueError:
  553.                 L
  554.                 e = L
  555.                 raise TestFailed, 'int(%s) raised ValueError: %s' % (`ss`, e)
  556.             except:
  557.                 0
  558.  
  559.         
  560.     
  561.  
  562. s = `-1 - sys.maxint`
  563.  
  564. try:
  565.     int(s[1:])
  566. except ValueError:
  567.     None if int(s) + 1 != -(sys.maxint) else L
  568.     None if int(s) + 1 != -(sys.maxint) else L
  569. except:
  570.     None if int(s) + 1 != -(sys.maxint) else L
  571.  
  572. raise TestFailed, 'int(%s)' % `s[1:]` + ' should raise ValueError'
  573. print 'isinstance'
  574.  
  575. class C:
  576.     pass
  577.  
  578.  
  579. class D(C):
  580.     pass
  581.  
  582.  
  583. class E:
  584.     pass
  585.  
  586. c = C()
  587. d = D()
  588. e = E()
  589. if not isinstance(c, C):
  590.     raise TestFailed, 'isinstance(c, C)'
  591.  
  592. if not isinstance(d, C):
  593.     raise TestFailed, 'isinstance(d, C)'
  594.  
  595. if isinstance(e, C):
  596.     raise TestFailed, 'isinstance(e, C)'
  597.  
  598. if isinstance(c, D):
  599.     raise TestFailed, 'isinstance(c, D)'
  600.  
  601. if isinstance('foo', E):
  602.     raise TestFailed, 'isinstance("Foo", E)'
  603.  
  604.  
  605. try:
  606.     isinstance(E, 'foo')
  607.     raise TestFailed, 'isinstance(E, "foo")'
  608. except TypeError:
  609.     pass
  610.  
  611. print 'issubclass'
  612. if not issubclass(D, C):
  613.     raise TestFailed, 'issubclass(D, C)'
  614.  
  615. if not issubclass(C, C):
  616.     raise TestFailed, 'issubclass(C, C)'
  617.  
  618. if issubclass(C, D):
  619.     raise TestFailed, 'issubclass(C, D)'
  620.  
  621.  
  622. try:
  623.     issubclass('foo', E)
  624.     raise TestFailed, 'issubclass("foo", E)'
  625. except TypeError:
  626.     pass
  627.  
  628.  
  629. try:
  630.     issubclass(E, 'foo')
  631.     raise TestFailed, 'issubclass(E, "foo")'
  632. except TypeError:
  633.     pass
  634.  
  635. print 'len'
  636. if len('123') != 3:
  637.     raise TestFailed, "len('123')"
  638.  
  639. if len(()) != 0:
  640.     raise TestFailed, 'len(())'
  641.  
  642. if len((1, 2, 3, 4)) != 4:
  643.     raise TestFailed, 'len((1, 2, 3, 4))'
  644.  
  645. if len([
  646.     1,
  647.     2,
  648.     3,
  649.     4]) != 4:
  650.     raise TestFailed, 'len([1, 2, 3, 4])'
  651.  
  652. if len({ }) != 0:
  653.     raise TestFailed, 'len({})'
  654.  
  655. if len({
  656.     'a': 1,
  657.     'b': 2 }) != 2:
  658.     raise TestFailed, "len({'a':1, 'b': 2})"
  659.  
  660. print 'long'
  661. if long(314) != 0x13AL:
  662.     raise TestFailed, 'long(314)'
  663.  
  664. if long(3.14) != 0x3L:
  665.     raise TestFailed, 'long(3.14)'
  666.  
  667. if long(0x13AL) != 0x13AL:
  668.     raise TestFailed, 'long(314L)'
  669.  
  670. if long(-3.14) != -0x3L:
  671.     raise TestFailed, 'long(-3.14)'
  672.  
  673. if long(3.9) != 0x3L:
  674.     raise TestFailed, 'long(3.9)'
  675.  
  676. if long(-3.9) != -0x3L:
  677.     raise TestFailed, 'long(-3.9)'
  678.  
  679. if long(3.5) != 0x3L:
  680.     raise TestFailed, 'long(3.5)'
  681.  
  682. if long(-3.5) != -0x3L:
  683.     raise TestFailed, 'long(-3.5)'
  684.  
  685. LL = [
  686.     ('1' + '0' * 20, 0xAL ** 20),
  687.     ('1' + '0' * 100, 0xAL ** 100)]
  688. for s, v in L + LL:
  689.     for sign in ('', '+', '-'):
  690.         for prefix in ('', ' ', '\t', '  \t\t  '):
  691.             ss = prefix + sign + s
  692.             vv = v
  693.             
  694.             try:
  695.                 if long(ss) != long(vv):
  696.                     raise TestFailed, 'int(%s)' % `ss`
  697.             except v:
  698.                 0 if sign == '-' and v is not ValueError else ('', ' ', '\t', '  \t\t  ')
  699.                 0 if sign == '-' and v is not ValueError else ('', ' ', '\t', '  \t\t  ')
  700.                 ('', '+', '-')
  701.             except ValueError:
  702.                 L + LL
  703.                 e = L + LL
  704.                 raise TestFailed, 'int(%s) raised ValueError: %s' % (`ss`, e)
  705.             except:
  706.                 0
  707.  
  708.         
  709.     
  710.  
  711. print 'map'
  712. if map(None, 'hello world') != [
  713.     'h',
  714.     'e',
  715.     'l',
  716.     'l',
  717.     'o',
  718.     ' ',
  719.     'w',
  720.     'o',
  721.     'r',
  722.     'l',
  723.     'd']:
  724.     raise TestFailed, "map(None, 'hello world')"
  725.  
  726. if map(None, 'abcd', 'efg') != [
  727.     ('a', 'e'),
  728.     ('b', 'f'),
  729.     ('c', 'g'),
  730.     ('d', None)]:
  731.     raise TestFailed, "map(None, 'abcd', 'efg')"
  732.  
  733. if map(None, range(10)) != [
  734.     0,
  735.     1,
  736.     2,
  737.     3,
  738.     4,
  739.     5,
  740.     6,
  741.     7,
  742.     8,
  743.     9]:
  744.     raise TestFailed, 'map(None, range(10))'
  745.  
  746. if map((lambda x: x * x), range(1, 4)) != [
  747.     1,
  748.     4,
  749.     9]:
  750.     raise TestFailed, 'map(lambda x: x*x, range(1,4))'
  751.  
  752.  
  753. try:
  754.     sqrt
  755. except ImportError:
  756.     
  757.     def sqrt(x):
  758.         return pow(x, 0.5)
  759.  
  760.  
  761. if map((lambda x: map(sqrt, x)), [
  762.     [
  763.         16,
  764.         4],
  765.     [
  766.         81,
  767.         9]]) != [
  768.     [
  769.         4.0,
  770.         2.0],
  771.     [
  772.         9.0,
  773.         3.0]]:
  774.     raise TestFailed, 'map(lambda x: map(sqrt,x), [[16, 4], [81, 9]])'
  775.  
  776. if map((lambda x, y: x + y), [
  777.     1,
  778.     3,
  779.     2], [
  780.     9,
  781.     1,
  782.     4]) != [
  783.     10,
  784.     4,
  785.     6]:
  786.     raise TestFailed, 'map(lambda x,y: x+y, [1,3,2], [9,1,4])'
  787.  
  788.  
  789. def plus(*v):
  790.     accu = 0
  791.     for i in v:
  792.         accu = accu + i
  793.     
  794.     return accu
  795.  
  796. if map(plus, [
  797.     1,
  798.     3,
  799.     7]) != [
  800.     1,
  801.     3,
  802.     7]:
  803.     raise TestFailed, 'map(plus, [1, 3, 7])'
  804.  
  805. if map(plus, [
  806.     1,
  807.     3,
  808.     7], [
  809.     4,
  810.     9,
  811.     2]) != [
  812.     1 + 4,
  813.     3 + 9,
  814.     7 + 2]:
  815.     raise TestFailed, 'map(plus, [1, 3, 7], [4, 9, 2])'
  816.  
  817. if map(plus, [
  818.     1,
  819.     3,
  820.     7], [
  821.     4,
  822.     9,
  823.     2], [
  824.     1,
  825.     1,
  826.     0]) != [
  827.     1 + 4 + 1,
  828.     3 + 9 + 1,
  829.     7 + 2 + 0]:
  830.     raise TestFailed, 'map(plus, [1, 3, 7], [4, 9, 2], [1, 1, 0])'
  831.  
  832. if map(None, Squares(10)) != [
  833.     0,
  834.     1,
  835.     4,
  836.     9,
  837.     16,
  838.     25,
  839.     36,
  840.     49,
  841.     64,
  842.     81]:
  843.     raise TestFailed, 'map(None, Squares(10))'
  844.  
  845. if map(int, Squares(10)) != [
  846.     0,
  847.     1,
  848.     4,
  849.     9,
  850.     16,
  851.     25,
  852.     36,
  853.     49,
  854.     64,
  855.     81]:
  856.     raise TestFailed, 'map(int, Squares(10))'
  857.  
  858. if map(None, Squares(3), Squares(2)) != [
  859.     (0, 0),
  860.     (1, 1),
  861.     (4, None)]:
  862.     raise TestFailed, 'map(None, Squares(3), Squares(2))'
  863.  
  864. if map(max, Squares(3), Squares(2)) != [
  865.     0,
  866.     1,
  867.     None]:
  868.     raise TestFailed, 'map(max, Squares(3), Squares(2))'
  869.  
  870. print 'max'
  871. if max('123123') != '3':
  872.     raise TestFailed, "max('123123')"
  873.  
  874. if max(1, 2, 3) != 3:
  875.     raise TestFailed, 'max(1, 2, 3)'
  876.  
  877. if max((1, 2, 3, 1, 2, 3)) != 3:
  878.     raise TestFailed, 'max((1, 2, 3, 1, 2, 3))'
  879.  
  880. if max([
  881.     1,
  882.     2,
  883.     3,
  884.     1,
  885.     2,
  886.     3]) != 3:
  887.     raise TestFailed, 'max([1, 2, 3, 1, 2, 3])'
  888.  
  889. if max(1, 0x2L, 3.0) != 3.0:
  890.     raise TestFailed, 'max(1, 2L, 3.0)'
  891.  
  892. if max(0x1L, 2.0, 3) != 3:
  893.     raise TestFailed, 'max(1L, 2.0, 3)'
  894.  
  895. if max(1.0, 2, 0x3L) != 0x3L:
  896.     raise TestFailed, 'max(1.0, 2, 3L)'
  897.  
  898. print 'min'
  899. if min('123123') != '1':
  900.     raise TestFailed, "min('123123')"
  901.  
  902. if min(1, 2, 3) != 1:
  903.     raise TestFailed, 'min(1, 2, 3)'
  904.  
  905. if min((1, 2, 3, 1, 2, 3)) != 1:
  906.     raise TestFailed, 'min((1, 2, 3, 1, 2, 3))'
  907.  
  908. if min([
  909.     1,
  910.     2,
  911.     3,
  912.     1,
  913.     2,
  914.     3]) != 1:
  915.     raise TestFailed, 'min([1, 2, 3, 1, 2, 3])'
  916.  
  917. if min(1, 0x2L, 3.0) != 1:
  918.     raise TestFailed, 'min(1, 2L, 3.0)'
  919.  
  920. if min(0x1L, 2.0, 3) != 0x1L:
  921.     raise TestFailed, 'min(1L, 2.0, 3)'
  922.  
  923. if min(1.0, 2, 0x3L) != 1.0:
  924.     raise TestFailed, 'min(1.0, 2, 3L)'
  925.  
  926.