<s> from __future__ import print_function <EOL> import numba . unittest_support as unittest <EOL> from numba import bytecode , interpreter , utils <EOL> from . import usecases <EOL> def interpret ( func ) : <EOL> bc = bytecode . ByteCode ( func = func ) <EOL> bc . dump ( ) <EOL> interp = interpreter . Interpreter ( bytecode = bc ) <EOL> interp . interpret ( ) <EOL> interp . dump ( utils . StringIO ( ) ) <EOL> return interp <EOL> class TestLoopDetection ( unittest . TestCase ) : <EOL> def assertLoops ( self , interp , expected ) : <EOL> cfg = interp . cfa . graph <EOL> self . assertEqual ( len ( cfg . loops ( ) ) , expected ) <EOL> def test_sum1d ( self ) : <EOL> interp = interpret ( usecases . sum1d ) <EOL> self . assertLoops ( interp , <NUM_LIT:1> ) <EOL> def test_sum2d ( self ) : <EOL> interp = interpret ( usecases . sum2d ) <EOL> self . assertLoops ( interp , <NUM_LIT:2> ) <EOL> def test_while_count ( self ) : <EOL> interp = interpret ( usecases . while_count ) <EOL> self . assertLoops ( interp , <NUM_LIT:1> ) <EOL> def test_copy_arrays ( self ) : <EOL> interp = interpret ( usecases . copy_arrays ) <EOL> self . assertLoops ( interp , <NUM_LIT:1> ) <EOL> def test_andor ( self ) : <EOL> interp = interpret ( usecases . andor ) <EOL> self . assertLoops ( interp , <NUM_LIT:0> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
