<s> import sys <EOL> class Coverage : <EOL> def __init__ ( self , testset_name ) : <EOL> self . testset_name = testset_name <EOL> self . lines = { } <EOL> def tracer ( self , frame , event , arg ) : <EOL> lineno = frame . f_lineno <EOL> filename = frame . f_globals [ "<STR_LIT>" ] <EOL> if filename [ - <NUM_LIT:4> : ] in [ "<STR_LIT>" , "<STR_LIT>" ] : <EOL> filename = filename [ : - <NUM_LIT:1> ] <EOL> self . lines [ filename ] [ lineno ] = self . lines . setdefault ( filename , { } ) . get ( lineno , <NUM_LIT:0> ) + <NUM_LIT:1> <EOL> return self . tracer <EOL> def start ( self ) : <EOL> sys . settrace ( self . tracer ) <EOL> def stop ( self ) : <EOL> sys . settrace ( None ) <EOL> def output ( self , * files ) : <EOL> print """<STR_LIT>""" % self . testset_name <EOL> print """<STR_LIT>""" % self . testset_name <EOL> for filename in files : <EOL> print """<STR_LIT>""" % filename <EOL> code = open ( filename ) . readlines ( ) <EOL> for lineno , line in enumerate ( code ) : <EOL> count = self . lines [ filename ] . get ( lineno + <NUM_LIT:1> , <NUM_LIT:0> ) <EOL> if count == <NUM_LIT:0> : <EOL> if line . strip ( ) in [ "<STR_LIT>" , "<STR_LIT>" ] or line . strip ( ) . startswith ( "<STR_LIT:#>" ) : <EOL> klass = "<STR_LIT:ignore>" <EOL> else : <EOL> klass = "<STR_LIT>" <EOL> else : <EOL> klass = "<STR_LIT>" <EOL> klass2 = klass + "<STR_LIT>" <EOL> print """<STR_LIT>""" % ( lineno + <NUM_LIT:1> , klass , count , klass2 , line . strip ( "<STR_LIT:\n>" ) ) <EOL> print """<STR_LIT>""" <EOL> print """<STR_LIT>""" <EOL> import sys <EOL> sys . path . append ( "<STR_LIT:..>" ) <EOL> import pyjs <EOL> def pyjs_tester ( filename , module ) : <EOL> output = pyjs . translate ( filename + "<STR_LIT>" , module ) <EOL> pyjs_test = [ <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ( "<STR_LIT>" , None ) , <EOL> ] <EOL> c = Coverage ( "<STR_LIT>" ) <EOL> c . start ( ) <EOL> for filename , module in pyjs_test : <EOL> pyjs_tester ( filename , module ) <EOL> c . stop ( ) <EOL> c . output ( "<STR_LIT>" ) </s>
