
    |h                         S SK r S SKrS SKrS SKrS SKJr  S SKJr  S SKJ	r	   " S S\5      r
\S:X  a  \ R                  " 5         gg)    Nnjit)TestCase)get_func_body_first_linenoc                   ~    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rSrg)TestFirstLineFinder   zv
The following methods contains tests that are sensitive to the source
locations w.r.t. the beginning of each method.
c                     [         R                  " 5       n[         R                  " U5      nUS   R                  R                  $ )N   )inspectcurrentframegetouterframesframef_code)selfr   caller_frames      Z/home/james-whalen/.local/lib/python3.13/site-packages/numba/tests/test_firstlinefinder.py_get_grandparent_caller_code0TestFirstLineFinder._get_grandparent_caller_code   s6    $$&--e4A$$+++    c                 d    U R                  5       nUR                  nU R                  XU-   5        g N)r   co_firstlinenoassertEqual)r   expectedoffset_from_callergrandparent_colnos        r   assert_line_location(TestFirstLineFinder.assert_line_location   s/    ::<++);#;<r   c                 V    [         S 5       n[        U5      nU R                  US5        g )Nc                      gN    r%   r   r   fooBTestFirstLineFinder.test_decorated_odd_comment_indent.<locals>.foo   s     r      r   r   r   r   r&   first_def_lines      r   !test_decorated_odd_comment_indent5TestFirstLineFinder.test_decorated_odd_comment_indent   s0    		 
	 4C8!!.!4r   c                 V    S n[        [        U5      5      nU R                  US5        g )Nc                      gr#   r%   r%   r   r   r&   DTestFirstLineFinder.test_undecorated_odd_comment_indent.<locals>.foo%   s    r      )r   r   r   r*   s      r   #test_undecorated_odd_comment_indent7TestFirstLineFinder.test_undecorated_odd_comment_indent$   s'    	 4DI>!!.!4r   c                 T    S n[        [        U5      5      nU R                  U5        g )Nc                      gr#   r%   r%   r   r   <lambda>9TestFirstLineFinder.test_unnamed_lambda.<locals>.<lambda>-   s    ar   )r   r   assertIsNoner*   s      r   test_unnamed_lambda'TestFirstLineFinder.test_unnamed_lambda,   s#    3DI>.)r   c                 R    S nU" 5       n[        U5      nU R                  US5        g )Nc                      [         S 5       n U $ )Nc                      gr#   r%   r%   r   r   r&   BTestFirstLineFinder.test_nested_function.<locals>.foo.<locals>.foo4   s     r   r   )r&   s    r   r&   5TestFirstLineFinder.test_nested_function.<locals>.foo3   s      Jr      )r   r   )r   r&   innerr+   s       r   test_nested_function(TestFirstLineFinder.test_nested_function2   s*    	 3E:!!.!4r   c                 V    [         S 5       n[        U5      nU R                  US5        g )Nc                      g r   r%   r%   r   r   r&   4TestFirstLineFinder.test_pass_statement.<locals>.foo@   s    r   r1   r)   r*   s      r   test_pass_statement'TestFirstLineFinder.test_pass_statement?   s0    		 
	 4C8!!.!4r   c                 d    Sn0 n[        X5        US   n[        U5      nU R                  U5        g )N$def foo():
            pass
        r&   )execr   r8   )r   sourceglobalnsr&   r+   s        r   test_string_eval$TestFirstLineFinder.test_string_evalG   s9     Vuo3C8.)r   c                     S n[        U5      XRR                  S5      U4nU[        R                  U'   [	        X!S5      n0 n[        Xx5        X   n	[        U	5      n
U R                  X5        g )NTrK   )len
splitlines	linecachecachecompilerK   r   r   )r   filenamerL   function_nameexpected_first_line	timestampentrycoderM   functionr+   s              r   _test_with_patched_linecache0TestFirstLineFinder._test_with_patched_linecacheT   so    
 	Vi):):4)@(K$)	! v0T* 4H==r   c                 :    SnSnSnSnU R                  X!UU5        g )NrJ   z<foo-basic>r&   r   r]   r   rL   rV   rW   rX   s        r    test_string_eval_linecache_basic4TestFirstLineFinder.test_string_eval_linecache_basicj   s0     !))(M*=	?r   c                 :    SnSnSnSnU R                  X!UU5        g )Nzif True:
        # indent designed to test against potential indent error in ast.parse

        def foo():
            pass
        z<foo-indent>r&   r@   r`   ra   s        r   !test_string_eval_linecache_indent5TestFirstLineFinder.test_string_eval_linecache_indentu   s0     "))(M*=	?r   c                 b    [         R                  " S5      nSnSnSnU R                  X!UU5        g )Nz
        def foo_gen():
            def foo():
                pass
            return foo

        generated_foo = foo_gen()
        z	<foo-gen>generated_foor(   textwrapdedentr]   ra   s        r   "test_string_eval_linecache_closure6TestFirstLineFinder.test_string_eval_linecache_closure   s<     "  '))(M*=	?r   c                 b    [         R                  " S5      nSnSnSnU R                  X!UU5        g )Nz
        def decorator(function):
            return function

        @decorator
        @decorator
        @decorator
        def decorated():
            pass
        z<foo-stacked-decorator>	decorated	   ri   ra   s        r   -test_string_eval_linecache_stacked_decoratorsATestFirstLineFinder.test_string_eval_linecache_stacked_decorators   s<     	" 	 -#))(M*=	?r   c                 :    SnSnSnSnU R                  X!UU5        g )Na  if 1:
        def decorator(function):
            return function

        def gen_decorated_foo():
            @decorator
            @decorator
            @decorator
            def _foo():
                pass

            return _foo

        foo_all = gen_decorated_foo()
        z	<foo-all>foo_all
   r`   ra   s        r   test_string_eval_linecache_all2TestFirstLineFinder.test_string_eval_linecache_all   s0      ! ))(M*=	?r   c                 V    [         S 5       n[        U5      nU R                  US5        g )Nc                      g r   r%   r%   r   r   r&   :TestFirstLineFinder.test_single_line_function.<locals>.foo   s    r   r   r)   r*   s      r   test_single_line_function-TestFirstLineFinder.test_single_line_function   s*    	 
3C8!!.!4r   c                 V    [         S 5       n[        U5      nU R                  US5        g )Nc                      gzDocstring
            Nr%   r%   r   r   r&   /TestFirstLineFinder.test_docstring.<locals>.foo   s     r   r@   r)   r*   s      r   test_docstring"TestFirstLineFinder.test_docstring   s0    		 
	
 4C8!!.!4r   c                 V    [         S 5       n[        U5      nU R                  US5        g )Nc                       gr   r%   r%   r   r   r&   1TestFirstLineFinder.test_docstring_2.<locals>.foo   s
    r   r@   r)   r*   s      r   test_docstring_2$TestFirstLineFinder.test_docstring_2   s0    		 
	 4C8!!.!4r   r%   N)__name__
__module____qualname____firstlineno____doc__r   r   r,   r2   r9   rB   rG   rN   r]   rb   re   rl   rq   rv   r{   r   r   __static_attributes__r%   r   r   r   r      s\    
,
=
55*55*>,	??? ?$?0555r   r   __main__)unittestrS   r   rj   numbar   numba.tests.supportr   numba.misc.firstlinefinderr   r   r   mainr%   r   r   <module>r      sA         ( AN5( N5b zMMO r   