<s> from __future__ import print_function <EOL> import numba . unittest_support as unittest <EOL> import sys <EOL> import numpy <EOL> from numba . compiler import compile_isolated <EOL> from numba import types <EOL> from . support import tag <EOL> def loop1 ( n ) : <EOL> s = <NUM_LIT:0> <EOL> for i in range ( n ) : <EOL> s += i <EOL> return s <EOL> def loop2 ( a , b ) : <EOL> s = <NUM_LIT:0> <EOL> for i in range ( a , b ) : <EOL> s += i <EOL> return s <EOL> def loop3 ( a , b , c ) : <EOL> s = <NUM_LIT:0> <EOL> for i in range ( a , b , c ) : <EOL> s += i <EOL> return s <EOL> def xrange_usecase ( n ) : <EOL> s = <NUM_LIT:0> <EOL> for i in xrange ( n ) : <EOL> s += i <EOL> return s <EOL> class TestRange ( unittest . TestCase ) : <EOL> @ tag ( '<STR_LIT>' ) <EOL> def test_loop1_int16 ( self ) : <EOL> pyfunc = loop1 <EOL> cres = compile_isolated ( pyfunc , [ types . int16 ] ) <EOL> cfunc = cres . entry_point <EOL> self . assertTrue ( cfunc ( <NUM_LIT:5> ) , pyfunc ( <NUM_LIT:5> ) ) <EOL> @ tag ( '<STR_LIT>' ) <EOL> def test_loop2_int16 ( self ) : <EOL> pyfunc = loop2 <EOL> cres = compile_isolated ( pyfunc , [ types . int16 , types . int16 ] ) <EOL> cfunc = cres . entry_point <EOL> self . assertTrue ( cfunc ( <NUM_LIT:1> , <NUM_LIT:6> ) , pyfunc ( <NUM_LIT:1> , <NUM_LIT:6> ) ) <EOL> @ tag ( '<STR_LIT>' ) <EOL> def test_loop3_int32 ( self ) : <EOL> pyfunc = loop3 <EOL> cres = compile_isolated ( pyfunc , [ types . int32 ] * <NUM_LIT:3> ) <EOL> cfunc = cres . entry_point <EOL> arglist = [ <EOL> ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> ) , <EOL> ( <NUM_LIT:2> , <NUM_LIT:8> , <NUM_LIT:3> ) , <EOL> ( - <NUM_LIT:10> , - <NUM_LIT:11> , - <NUM_LIT:10> ) , <EOL> ( - <NUM_LIT:10> , - <NUM_LIT:10> , - <NUM_LIT:2> ) , <EOL> ] <EOL> for args in arglist : <EOL> self . assertEqual ( cfunc ( * args ) , pyfunc ( * args ) ) <EOL> @ tag ( '<STR_LIT>' ) <EOL> @ unittest . skipIf ( sys . version_info >= ( <NUM_LIT:3> , ) , "<STR_LIT>" ) <EOL> def test_xrange ( self ) : <EOL> pyfunc = xrange_usecase <EOL> cres = compile_isolated ( pyfunc , ( types . int32 , ) ) <EOL> cfunc = cres . entry_point <EOL> self . assertEqual ( cfunc ( <NUM_LIT:5> ) , pyfunc ( <NUM_LIT:5> ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
