<s> import re <EOL> import sys <EOL> import nose <EOL> """<STR_LIT>""" <EOL> doublepat = re . compile ( r'<STR_LIT>' ) <EOL> intpat = re . compile ( r'<STR_LIT>' ) <EOL> def parse_value ( value ) : <EOL> if doublepat . match ( value ) : <EOL> n = float ( value ) <EOL> assert n < pow ( <NUM_LIT:2> , <NUM_LIT> ) , "<STR_LIT>" <EOL> return round ( n , <NUM_LIT:2> ) <EOL> elif intpat . match ( value ) : <EOL> return int ( value ) <EOL> else : <EOL> return value <EOL> def verify ( testout , expected , ordered ) : <EOL> tuplepat = re . compile ( r'<STR_LIT>' ) <EOL> test = ( { } , [ ] ) <EOL> expect = ( { } , [ ] ) <EOL> def addTuple ( tc , t ) : <EOL> if ordered : <EOL> tcl = tc [ <NUM_LIT:1> ] <EOL> tcl . append ( t ) <EOL> else : <EOL> tcs = tc [ <NUM_LIT:0> ] <EOL> if t not in tcs : <EOL> tcs [ t ] = <NUM_LIT:1> <EOL> else : <EOL> tcs [ t ] += <NUM_LIT:1> <EOL> with open ( testout , '<STR_LIT:r>' ) as file : <EOL> for line in file . readlines ( ) : <EOL> m = tuplepat . search ( line ) <EOL> if m : <EOL> tlist = [ ] <EOL> for number in m . group ( <NUM_LIT:1> ) . split ( '<STR_LIT:U+002C>' ) : <EOL> if number == '<STR_LIT>' : <EOL> break <EOL> tlist . append ( parse_value ( number ) ) <EOL> t = tuple ( tlist ) <EOL> addTuple ( test , t ) <EOL> with open ( expected , '<STR_LIT:r>' ) as file : <EOL> for line in file . readlines ( ) : <EOL> tlist = [ ] <EOL> for number in line . split ( ) : <EOL> tlist . append ( parse_value ( number ) ) <EOL> t = tuple ( tlist ) <EOL> addTuple ( expect , t ) <EOL> print test <EOL> print expect <EOL> assert test == expect , "<STR_LIT>" % ( test , expect ) <EOL> print "<STR_LIT>" <EOL> def verify_store ( testout , expected , ordered ) : <EOL> numpat = re . compile ( r'<STR_LIT>' ) <EOL> test = ( { } , [ ] ) <EOL> expect = ( { } , [ ] ) <EOL> def addTuple ( tc , t ) : <EOL> if ordered : <EOL> tcl = tc [ <NUM_LIT:1> ] <EOL> tcl . append ( t ) <EOL> else : <EOL> tcs = tc [ <NUM_LIT:0> ] <EOL> if t not in tcs : <EOL> tcs [ t ] = <NUM_LIT:1> <EOL> else : <EOL> tcs [ t ] += <NUM_LIT:1> <EOL> with open ( testout , '<STR_LIT:r>' ) as file : <EOL> for line in file . readlines ( ) : <EOL> tlist = [ ] <EOL> for number in numpat . finditer ( line ) : <EOL> tlist . append ( int ( number . group ( <NUM_LIT:0> ) ) ) <EOL> t = tuple ( tlist ) <EOL> addTuple ( test , t ) <EOL> with open ( expected , '<STR_LIT:r>' ) as file : <EOL> for line in file . readlines ( ) : <EOL> tlist = [ ] <EOL> for number in numpat . finditer ( line ) : <EOL> tlist . append ( int ( number . group ( <NUM_LIT:0> ) ) ) <EOL> t = tuple ( tlist ) <EOL> addTuple ( expect , t ) <EOL> print test <EOL> print expect <EOL> assert test == expect , "<STR_LIT>" % ( test , expect ) <EOL> print "<STR_LIT>" <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> testout = sys . argv [ <NUM_LIT:1> ] <EOL> expected = sys . argv [ <NUM_LIT:2> ] <EOL> ordered = False <EOL> if len ( sys . argv ) > <NUM_LIT:3> : <EOL> if sys . argv [ <NUM_LIT:3> ] == '<STR_LIT:o>' : <EOL> ordered = True <EOL> verify ( testout , expected , ordered ) </s>
