def exercise_memoize(): diagnostic = [] def f(x): """ Documentation for function f """ diagnostic.append('+') return x + 1 mf = oop.memoize(f) assert mf(0) == 1 assert diagnostic == ['+'] assert mf(0) == 1 assert diagnostic == ['+'] assert mf(1) == 2 assert diagnostic == ['+'] * 2 assert mf(0) == 1 assert diagnostic == ['+'] * 2 assert mf(1) == 2 assert diagnostic == ['+'] * 2 try: mf(x=1) except TypeError as e: pass else: raise Exception_expected assert mf.__doc__ == """ Documentation for function f """
def exercise_memoize(): diagnostic = [] def f(x): """ Documentation for function f """ diagnostic.append('+') return x+1 mf = oop.memoize(f) assert mf(0) == 1 assert diagnostic == ['+'] assert mf(0) == 1 assert diagnostic == ['+'] assert mf(1) == 2 assert diagnostic == ['+']*2 assert mf(0) == 1 assert diagnostic == ['+']*2 assert mf(1) == 2 assert diagnostic == ['+']*2 try: mf(x=1) except TypeError, e: pass