mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Merge alpha100 branch back to main trunk
This commit is contained in:
parent
2979b01ff8
commit
b6775db241
176 changed files with 5302 additions and 3668 deletions
|
@ -121,6 +121,25 @@ if reduce(lambda x, y: x*y, range(2,8), 1) <> 5040:
|
|||
raise TestFailed, 'reduce(): compute 7!'
|
||||
if reduce(lambda x, y: x*y, range(2,21), 1L) <> 2432902008176640000L:
|
||||
raise TestFailed, 'reduce(): compute 20!, use long'
|
||||
class Squares:
|
||||
def __init__(self, max):
|
||||
self.max = max
|
||||
self.sofar = []
|
||||
def __len__(self): return len(self.sofar)
|
||||
def __getitem__(self, i):
|
||||
if not 0 <= i < self.max: raise IndexError
|
||||
n = len(self.sofar)
|
||||
while n <= i:
|
||||
self.sofar.append(n*n)
|
||||
n = n+1
|
||||
return self.sofar[i]
|
||||
if reduce(lambda x, y: x+y, Squares(10)) != 285:
|
||||
raise TestFailed, 'reduce(<+>, Squares(10))'
|
||||
if reduce(lambda x, y: x+y, Squares(10), 0) != 285:
|
||||
raise TestFailed, 'reduce(<+>, Squares(10), 0)'
|
||||
if reduce(lambda x, y: x+y, Squares(0), 0) != 0:
|
||||
raise TestFailed, 'reduce(<+>, Squares(0), 0)'
|
||||
|
||||
|
||||
print 'reload'
|
||||
import string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue