<s> import pyfora . StdinCache as StdinCache <EOL> import ast <EOL> import textwrap <EOL> import unittest <EOL> def dedentAndStrip ( text ) : <EOL> lines = textwrap . dedent ( text ) . split ( "<STR_LIT:\n>" ) <EOL> while lines and lines [ <NUM_LIT:0> ] == "<STR_LIT>" : <EOL> lines . pop ( <NUM_LIT:0> ) <EOL> while lines and lines [ - <NUM_LIT:1> ] == "<STR_LIT>" : <EOL> lines . pop ( ) <EOL> return "<STR_LIT:\n>" . join ( lines ) <EOL> class StdinCache_test ( unittest . TestCase ) : <EOL> def test_stdinCache ( self ) : <EOL> stdinCache = StdinCache . StdinCache ( ) <EOL> stdinCache . refreshFromText ( <EOL> dedentAndStrip ( <EOL> """<STR_LIT>""" <EOL> ) <EOL> ) <EOL> self . assertEqual ( len ( stdinCache . blocks ) , <NUM_LIT:2> ) <EOL> def test_stdinCache_trailing_backslash ( self ) : <EOL> stdinCache = StdinCache . StdinCache ( ) <EOL> stdinCache . refreshFromText ( <EOL> dedentAndStrip ( <EOL> """<STR_LIT>""" <EOL> ) <EOL> ) <EOL> self . assertEqual ( len ( stdinCache . blocks ) , <NUM_LIT:1> ) <EOL> def test_stdinCache_trailing_backslash_2 ( self ) : <EOL> stdinCache = StdinCache . StdinCache ( ) <EOL> stdinCache . refreshFromText ( <EOL> dedentAndStrip ( <EOL> """<STR_LIT>""" <EOL> ) <EOL> ) <EOL> self . assertEqual ( len ( stdinCache . blocks ) , <NUM_LIT:1> ) <EOL> def test_stdinCache_trailing_backslash_3 ( self ) : <EOL> stdinCache = StdinCache . StdinCache ( ) <EOL> stdinCache . refreshFromText ( <EOL> dedentAndStrip ( <EOL> """<STR_LIT>""" <EOL> ) <EOL> ) <EOL> self . assertEqual ( len ( stdinCache . blocks ) , <NUM_LIT:2> ) <EOL> def test_stdinCache_2 ( self ) : <EOL> stdinCache = StdinCache . StdinCache ( ) <EOL> stdinCache . refreshFromText ( <EOL> dedentAndStrip ( <EOL> """<STR_LIT>""" <EOL> ) <EOL> ) <EOL> self . assertEqual ( len ( stdinCache . blocks ) , <NUM_LIT:3> , stdinCache . blocks ) <EOL> self . assertEqual ( len ( stdinCache . blocks [ <NUM_LIT:0> ] ) , <NUM_LIT:4> ) <EOL> def test_stdinCache_find ( self ) : <EOL> stdinCache = StdinCache . StdinCache ( ) <EOL> stdinCache . refreshFromText ( <EOL> dedentAndStrip ( <EOL> """<STR_LIT>""" <EOL> ) <EOL> ) <EOL> e1 = compile ( ast . parse ( "<STR_LIT>" ) , "<STR_LIT>" , '<STR_LIT>' ) <EOL> e2 = compile ( ast . parse ( "<STR_LIT>" ) , "<STR_LIT>" , '<STR_LIT>' ) <EOL> self . assertEqual ( stdinCache . findCodeLineNumberWithinStdin ( e1 ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( stdinCache . findCodeLineNumberWithinStdin ( e2 ) , <NUM_LIT:2> ) <EOL> def f ( ) : <EOL> def g ( ) : <EOL> return <NUM_LIT:10> <EOL> return g <EOL> g = f ( ) <EOL> self . assertEqual ( stdinCache . findCodeLineNumberWithinStdin ( f . func_code ) , <NUM_LIT:4> ) <EOL> self . assertEqual ( stdinCache . findCodeLineNumberWithinStdin ( g . func_code ) , <NUM_LIT:5> ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
