Ë
    èÿæi¯  ã                   óŒ   — d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlm	Z	  G d„ de«      Z
edk(  r e j                  «        yy)é    N©Únjit)ÚTestCase)Úget_func_body_first_linenoc                   óv   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zy)ÚTestFirstLineFinderz‚
    The following methods contains tests that are sensitive to the source
    locations w.r.t. the beginning of each method.
    c                 ó†   — t        j                  «       }t        j                  |«      }|d   j                  j                  S )Né   )ÚinspectÚcurrentframeÚgetouterframesÚframeÚf_code)Úselfr   Úcaller_frames      úu/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/numba/tests/test_firstlinefinder.pyÚ_get_grandparent_caller_codez0TestFirstLineFinder._get_grandparent_caller_code   s6   € Ü×$Ñ$Ó&ˆÜ×-Ñ-¨eÓ4ˆØ˜A‰×$Ñ$×+Ñ+Ð+ó    c                 óf   — | j                  «       }|j                  }| j                  |||z   «       y ©N)r   Úco_firstlinenoÚassertEqual)r   ÚexpectedÚoffset_from_callerÚgrandparent_coÚlnos        r   Úassert_line_locationz(TestFirstLineFinder.assert_line_location   s1   € Ø×:Ñ:Ó<ˆØ×+Ñ+ˆØ×Ñ˜ 3Ð);Ñ#;Õ<r   c                 óV   — t         d„ «       }t        |«      }| j                  |d«       y )Nc                   ó   — y©Né   © r"   r   r   ÚfoozBTestFirstLineFinder.test_decorated_odd_comment_indent.<locals>.foo   s   € ð r   é   ©r   r   r   ©r   r#   Úfirst_def_lines      r   Ú!test_decorated_odd_comment_indentz5TestFirstLineFinder.test_decorated_odd_comment_indent   s0   € Ü	ñ	ó 
ð	ô 4°CÓ8ˆØ×!Ñ! .°!Õ4r   c                 óV   — d„ }t        t        |«      «      }| j                  |d«       y )Nc                   ó   — yr    r"   r"   r   r   r#   zDTestFirstLineFinder.test_undecorated_odd_comment_indent.<locals>.foo%   s   € àr   é   )r   r   r   r&   s      r   Ú#test_undecorated_odd_comment_indentz7TestFirstLineFinder.test_undecorated_odd_comment_indent$   s'   € ò	ô 4´D¸³IÓ>ˆØ×!Ñ! .°!Õ4r   c                 óT   — d„ }t        t        |«      «      }| j                  |«       y )Nc                   ó   — yr    r"   r"   r   r   Ú<lambda>z9TestFirstLineFinder.test_unnamed_lambda.<locals>.<lambda>-   s   € �ar   )r   r   ÚassertIsNoner&   s      r   Útest_unnamed_lambdaz'TestFirstLineFinder.test_unnamed_lambda,   s#   € ÙˆÜ3´D¸³IÓ>ˆà×Ñ˜.Õ)r   c                 óR   — d„ } |«       }t        |«      }| j                  |d«       y )Nc                  ó   — t         d„ «       } | S )Nc                   ó   — yr    r"   r"   r   r   r#   zBTestFirstLineFinder.test_nested_function.<locals>.foo.<locals>.foo4   s   € ð r   r   )r#   s    r   r#   z5TestFirstLineFinder.test_nested_function.<locals>.foo3   s   € Üñó ðð ˆJr   é   )r   r   )r   r#   Úinnerr'   s       r   Útest_nested_functionz(TestFirstLineFinder.test_nested_function2   s*   € ò	ñ “ˆÜ3°EÓ:ˆØ×!Ñ! .°!Õ4r   c                 óV   — t         d„ «       }t        |«      }| j                  |d«       y )Nc                   ó   — y r   r"   r"   r   r   r#   z4TestFirstLineFinder.test_pass_statement.<locals>.foo@   s   € àr   r+   r%   r&   s      r   Útest_pass_statementz'TestFirstLineFinder.test_pass_statement?   s0   € Ü	ñ	ó 
ð	ô 4°CÓ8ˆØ×!Ñ! .°!Õ4r   c                 óf   — d}i }t        ||«       |d   }t        |«      }| j                  |«       y )Nú$def foo():
            pass
        r#   )Úexecr   r0   )r   ÚsourceÚglobalnsr#   r'   s        r   Útest_string_evalz$TestFirstLineFinder.test_string_evalG   s;   € ðˆð ˆÜˆV�XÔØ�u‰oˆä3°CÓ8ˆà×Ñ˜.Õ)r   c                 óä   — d }t        |«      ||j                  d«      |f}|t        j                  |<   t	        ||d«      }i }t        ||«       ||   }	t        |	«      }
| j                  |
|«       y )NTr=   )ÚlenÚ
splitlinesÚ	linecacheÚcacheÚcompiler=   r   r   )r   Úfilenamer>   Úfunction_nameÚexpected_first_lineÚ	timestampÚentryÚcoder?   Úfunctionr'   s              r   Ú_test_with_patched_linecachez0TestFirstLineFinder._test_with_patched_linecacheT   sz   € ð
 ˆ	Ü�V“˜i¨×):Ñ):¸4Ó)@À(ÐKˆØ$)Œ	�‰˜Ñ!ô �v˜x¨Ó0ˆàˆÜˆT�8ÔØ˜MÑ*ˆô 4°HÓ=ˆØ×Ñ˜Ð)<Õ=r   c                 ó<   — d}d}d}d}| j                  ||||«       y )Nr<   z<foo-basic>r#   r
   ©rN   ©r   r>   rG   rH   rI   s        r   Ú test_string_eval_linecache_basicz4TestFirstLineFinder.test_string_eval_linecache_basicj   s2   € ðˆð !ˆØˆØÐØ×)Ñ)¨(°F¸MØ*=õ	?r   c                 ó<   — d}d}d}d}| j                  ||||«       y )Nz„if True:
        # indent designed to test against potential indent error in ast.parse

        def foo():
            pass
        z<foo-indent>r#   r5   rP   rQ   s        r   Ú!test_string_eval_linecache_indentz5TestFirstLineFinder.test_string_eval_linecache_indentu   s2   € ðˆð "ˆØˆØÐØ×)Ñ)¨(°F¸MØ*=õ	?r   c                 ób   — t        j                  d«      }d}d}d}| j                  ||||«       y )Nz†
        def foo_gen():
            def foo():
                pass
            return foo

        generated_foo = foo_gen()
        z	<foo-gen>Úgenerated_foor$   ©ÚtextwrapÚdedentrN   rQ   s        r   Ú"test_string_eval_linecache_closurez6TestFirstLineFinder.test_string_eval_linecache_closureƒ   s>   € Ü—‘ð "ó ˆð ˆØ'ˆØÐØ×)Ñ)¨(°F¸MØ*=õ	?r   c                 ób   — t        j                  d«      }d}d}d}| j                  ||||«       y )Nzª
        def decorator(function):
            return function

        @decorator
        @decorator
        @decorator
        def decorated():
            pass
        z<foo-stacked-decorator>Ú	decoratedé	   rW   rQ   s        r   Ú-test_string_eval_linecache_stacked_decoratorszATestFirstLineFinder.test_string_eval_linecache_stacked_decorators“   s>   € Ü—‘ð 	"ó 	ˆð -ˆØ#ˆØÐØ×)Ñ)¨(°F¸MØ*=õ	?r   c                 ó<   — d}d}d}d}| j                  ||||«       y )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é
   rP   rQ   s        r   Útest_string_eval_linecache_allz2TestFirstLineFinder.test_string_eval_linecache_all¥   s2   € ðˆð  ˆØ!ˆØ ÐØ×)Ñ)¨(°F¸MØ*=õ	?r   c                 óV   — t         d„ «       }t        |«      }| j                  |d«       y )Nc                   ó   — y r   r"   r"   r   r   r#   z:TestFirstLineFinder.test_single_line_function.<locals>.foo¾   s   € Ør   r
   r%   r&   s      r   Útest_single_line_functionz-TestFirstLineFinder.test_single_line_function½   s*   € Ü	Ùó 
Øä3°CÓ8ˆØ×!Ñ! .°!Õ4r   c                 óV   — t         d„ «       }t        |«      }| j                  |d«       y )Nc                   ó   — y©zDocstring
            Nr"   r"   r   r   r#   z/TestFirstLineFinder.test_docstring.<locals>.fooÅ   s   € ð r   r5   r%   r&   s      r   Útest_docstringz"TestFirstLineFinder.test_docstringÄ   s0   € Ü	ñ	ó 
ð	ô
 4°CÓ8ˆØ×!Ñ! .°!Õ4r   c                 óV   — t         d„ «       }t        |«      }| j                  |d«       y )Nc                   ó   — 	 yrh   r"   r"   r   r   r#   z1TestFirstLineFinder.test_docstring_2.<locals>.fooÏ   s
   € ðàr   r5   r%   r&   s      r   Útest_docstring_2z$TestFirstLineFinder.test_docstring_2Î   s0   € Ü	ñ	ó 
ð	ô 4°CÓ8ˆØ×!Ñ! .°!Õ4r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r(   r,   r1   r7   r:   r@   rN   rR   rT   rZ   r^   rb   re   ri   rl   r"   r   r   r   r      s\   „ ñò
,ò
=ò
5ò5ò*ò5ò5ò*ò>ò,	?ò?ò?ò ?ò$?ò05ò5ó5r   r   Ú__main__)ÚunittestrD   r   rX   Únumbar   Únumba.tests.supportr   Únumba.misc.firstlinefinderr   r   rm   Úmainr"   r   r   Ú<module>rw      sC   ðÛ Û Û Û å Ý (Ý AôN5˜(ô N5ðb ˆzÒØ€H‡M�M…Oð r   