<s> from __future__ import print_function , absolute_import <EOL> import numpy <EOL> from numba import config , cuda , jit <EOL> from numba . cuda . testing import unittest <EOL> def foo ( ary ) : <EOL> x = cuda . threadIdx . x <EOL> if x == <NUM_LIT:1> : <EOL> ary . shape [ - x ] <EOL> class TestException ( unittest . TestCase ) : <EOL> def test_exception ( self ) : <EOL> unsafe_foo = cuda . jit ( foo ) <EOL> safe_foo = cuda . jit ( debug = True ) ( foo ) <EOL> if not config . ENABLE_CUDASIM : <EOL> unsafe_foo [ <NUM_LIT:1> , <NUM_LIT:2> ] ( numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:1> ] ) ) <EOL> with self . assertRaises ( IndexError ) as cm : <EOL> safe_foo [ <NUM_LIT:1> , <NUM_LIT:2> ] ( numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:1> ] ) ) <EOL> self . assertIn ( "<STR_LIT>" , str ( cm . exception ) ) <EOL> def test_user_raise ( self ) : <EOL> @ cuda . jit ( debug = True ) <EOL> def foo ( do_raise ) : <EOL> if do_raise : <EOL> raise ValueError <EOL> foo [ <NUM_LIT:1> , <NUM_LIT:1> ] ( False ) <EOL> with self . assertRaises ( ValueError ) : <EOL> foo [ <NUM_LIT:1> , <NUM_LIT:1> ] ( True ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
