<s> import unittest <EOL> from sre_yield import cachingseq <EOL> class CachingFuncSequenceTest ( unittest . TestCase ) : <EOL> def testLimits ( self ) : <EOL> c = cachingseq . CachingFuncSequence ( lambda i : i , <NUM_LIT:10> ) <EOL> self . assertEqual ( <NUM_LIT:9> , c [ <NUM_LIT:9> ] ) <EOL> self . assertEqual ( <NUM_LIT:9> , c [ - <NUM_LIT:1> ] ) <EOL> self . assertEqual ( <NUM_LIT:0> , c [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( <NUM_LIT:0> , c [ - <NUM_LIT:10> ] ) <EOL> self . assertRaises ( IndexError , lambda : c [ <NUM_LIT:10> ] ) <EOL> self . assertRaises ( IndexError , lambda : c [ <NUM_LIT:11> ] ) <EOL> self . assertRaises ( IndexError , lambda : c [ - <NUM_LIT:11> ] ) <EOL> self . assertRaises ( IndexError , lambda : c [ - <NUM_LIT:12> ] ) <EOL> self . assertEqual ( <NUM_LIT:2> , len ( c . _cache ) ) <EOL> c . func = lambda i : '<STR_LIT>' <EOL> self . assertEqual ( '<STR_LIT>' , c [ <NUM_LIT:1> ] ) <EOL> self . assertEqual ( <NUM_LIT:0> , c [ <NUM_LIT:0> ] ) <EOL> def testIter ( self ) : <EOL> c = cachingseq . CachingFuncSequence ( lambda i : i , <NUM_LIT:10> ) <EOL> self . assertEqual ( <NUM_LIT:0> , len ( c . _cache ) ) <EOL> self . assertEqual ( <NUM_LIT:10> , len ( c ) ) <EOL> self . assertEqual ( list ( range ( <NUM_LIT:10> ) ) , list ( c ) ) <EOL> self . assertEqual ( <NUM_LIT:10> , len ( c . _cache ) ) <EOL> def testIncFunc ( self ) : <EOL> def first_func ( x ) : <EOL> assert x == <NUM_LIT:0> <EOL> return <NUM_LIT:1> <EOL> def inc_func ( i , prev ) : <EOL> return prev * <NUM_LIT:2> <EOL> c = cachingseq . CachingFuncSequence ( first_func , <NUM_LIT:10> , inc_func ) <EOL> self . assertEqual ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:8> , <NUM_LIT:16> , <NUM_LIT:32> , <NUM_LIT:64> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , list ( c ) ) </s>
