MCPcopy Index your code
hub / github.com/RustPython/RustPython / Squares

Class Squares

Lib/test/test_functools.py:974–988  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

972class TestReduce:
973 def test_reduce(self):
974 class Squares:
975 def __init__(self, max):
976 self.max = max
977 self.sofar = []
978
979 def __len__(self):
980 return len(self.sofar)
981
982 def __getitem__(self, i):
983 if not 0 <= i < self.max: raise IndexError
984 n = len(self.sofar)
985 while n <= i:
986 self.sofar.append(n*n)
987 n += 1
988 return self.sofar[i]
989 def add(x, y):
990 return x + y
991 self.assertEqual(self.reduce(add, ['a', 'b', 'c'], ''), 'abc')

Callers 1

test_reduceMethod · 0.70

Calls

no outgoing calls

Tested by 1

test_reduceMethod · 0.56