§
    2@ÄjŒ  ã                   ó”   — 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        ¦   «          dS dS )é    N©Únjit)ÚTestCase)Úget_func_body_first_linenoc                   óx   — 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dS )ÚTestFirstLineFinderz‚
    The following methods contains tests that are sensitive to the source
    locations w.r.t. the beginning of each method.
    c                 ót   — t          j        ¦   «         }t          j        |¦  «        }|d         j        j        S )Né   )ÚinspectÚcurrentframeÚgetouterframesÚframeÚf_code)Úselfr   Úcaller_frames      úQC:\Projects\Historical\venv\Lib\site-packages\numba/tests/test_firstlinefinder.pyÚ_get_grandparent_caller_codez0TestFirstLineFinder._get_grandparent_caller_code   s0   € ÝÔ$Ñ&Ô&ˆÝÔ-¨eÑ4Ô4ˆØ˜AŒÔ$Ô+Ð+ó    c                 ón   — |                       ¦   «         }|j        }|                      |||z   ¦  «         d S ©N)r   Úco_firstlinenoÚassertEqual)r   ÚexpectedÚoffset_from_callerÚgrandparent_coÚlnos        r   Úassert_line_locationz(TestFirstLineFinder.assert_line_location   s=   € Ø×:Ò:Ñ<Ô<ˆØÔ+ˆØ×Ò˜ 3Ð);Ñ#;Ñ<Ô<Ð<Ð<Ð<r   c                 óp   — t           d„ ¦   «         }t          |¦  «        }|                      |d¦  «         d S )Nc                  ó   — dS ©Né   © r"   r   r   ÚfoozBTestFirstLineFinder.test_decorated_odd_comment_indent.<locals>.foo   s	   € ð �1r   é   ©r   r   r   ©r   r#   Úfirst_def_lines      r   Ú!test_decorated_odd_comment_indentz5TestFirstLineFinder.test_decorated_odd_comment_indent   sF   € Ý	ð	ð 	ñ 
Œð	õ 4°CÑ8Ô8ˆØ×!Ò! .°!Ñ4Ô4Ð4Ð4Ð4r   c                 óp   — d„ }t          t          |¦  «        ¦  «        }|                      |d¦  «         d S )Nc                  ó   — dS r    r"   r"   r   r   r#   zDTestFirstLineFinder.test_undecorated_odd_comment_indent.<locals>.foo%   s   € à�1r   é   )r   r   r   r&   s      r   Ú#test_undecorated_odd_comment_indentz7TestFirstLineFinder.test_undecorated_odd_comment_indent$   sB   € ð	ð 	ð 	õ 4µD¸±I´IÑ>Ô>ˆØ×!Ò! .°!Ñ4Ô4Ð4Ð4Ð4r   c                 ón   — d„ }t          t          |¦  «        ¦  «        }|                      |¦  «         d S )Nc                  ó   — dS r    r"   r"   r   r   ú<lambda>z9TestFirstLineFinder.test_unnamed_lambda.<locals>.<lambda>-   s   € �a€ r   )r   r   ÚassertIsNoner&   s      r   Útest_unnamed_lambdaz'TestFirstLineFinder.test_unnamed_lambda,   s6   € ØˆiˆÝ3µD¸±I´IÑ>Ô>ˆà×Ò˜.Ñ)Ô)Ð)Ð)Ð)r   c                 ój   — d„ } |¦   «         }t          |¦  «        }|                      |d¦  «         d S )Nc                  ó&   — t           d„ ¦   «         } | S )Nc                  ó   — dS r    r"   r"   r   r   r#   zBTestFirstLineFinder.test_nested_function.<locals>.foo.<locals>.foo4   s	   € ð �qr   r   )r#   s    r   r#   z5TestFirstLineFinder.test_nested_function.<locals>.foo3   s"   € Ýðð ñ ŒTðð ˆJr   é   )r   r   )r   r#   Úinnerr'   s       r   Útest_nested_functionz(TestFirstLineFinder.test_nested_function2   sG   € ð	ð 	ð 	ð �‘”ˆÝ3°EÑ:Ô:ˆØ×!Ò! .°!Ñ4Ô4Ð4Ð4Ð4r   c                 óp   — t           d„ ¦   «         }t          |¦  «        }|                      |d¦  «         d S )Nc                  ó   — d S r   r"   r"   r   r   r#   z4TestFirstLineFinder.test_pass_statement.<locals>.foo@   s   € àˆDr   r+   r%   r&   s      r   Útest_pass_statementz'TestFirstLineFinder.test_pass_statement?   sF   € Ý	ð	ð 	ñ 
Œð	õ 4°CÑ8Ô8ˆØ×!Ò! .°!Ñ4Ô4Ð4Ð4Ð4r   c                 ó†   — d}i }t          ||¦  «         |d         }t          |¦  «        }|                      |¦  «         d S )Nú$def foo():
            pass
        r#   )Úexecr   r0   )r   ÚsourceÚglobalnsr#   r'   s        r   Útest_string_evalz$TestFirstLineFinder.test_string_evalG   sP   € ðˆð ˆÝˆV�XÑÔÐØ�uŒoˆå3°CÑ8Ô8ˆà×Ò˜.Ñ)Ô)Ð)Ð)Ð)r   c                 ó  — d }t          |¦  «        ||                     d¦  «        |f}|t          j        |<   t	          ||d¦  «        }i }t          ||¦  «         ||         }	t          |	¦  «        }
|                      |
|¦  «         d S )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   s•   € ð
 ˆ	Ý�V‘”˜i¨×):Ò):¸4Ñ)@Ô)@À(ÐKˆØ$)�	Œ˜Ñ!õ �v˜x¨Ñ0Ô0ˆàˆÝˆT�8ÑÔÐØ˜MÔ*ˆõ 4°HÑ=Ô=ˆØ×Ò˜Ð)<Ñ=Ô=Ð=Ð=Ð=r   c                 óF   — d}d}d}d}|                       ||||¦  «         d S )Nr<   z<foo-basic>r#   r
   ©rN   ©r   r>   rG   rH   rI   s        r   Ú test_string_eval_linecache_basicz4TestFirstLineFinder.test_string_eval_linecache_basicj   sF   € ðˆð !ˆØˆØÐØ×)Ò)¨(°F¸MØ*=ñ	?ô 	?ð 	?ð 	?ð 	?r   c                 óF   — d}d}d}d}|                       ||||¦  «         d S )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   sF   € ðˆð "ˆØˆØÐØ×)Ò)¨(°F¸MØ*=ñ	?ô 	?ð 	?ð 	?ð 	?r   c                 ój   — t          j        d¦  «        }d}d}d}|                      ||||¦  «         d S )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ƒ   sU   € Ý”ð "ñ ô ˆð ˆØ'ˆØÐØ×)Ò)¨(°F¸MØ*=ñ	?ô 	?ð 	?ð 	?ð 	?r   c                 ój   — t          j        d¦  «        }d}d}d}|                      ||||¦  «         d S )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“   sU   € Ý”ð 	"ñ 	ô 	ˆð -ˆØ#ˆØÐØ×)Ò)¨(°F¸MØ*=ñ	?ô 	?ð 	?ð 	?ð 	?r   c                 óF   — d}d}d}d}|                       ||||¦  «         d S )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¥   sF   € ðˆð  ˆØ!ˆØ ÐØ×)Ò)¨(°F¸MØ*=ñ	?ô 	?ð 	?ð 	?ð 	?r   c                 óp   — t           d„ ¦   «         }t          |¦  «        }|                      |d¦  «         d S )Nc                  ó   — d S r   r"   r"   r   r   r#   z:TestFirstLineFinder.test_single_line_function.<locals>.foo¾   s   € Ø�4r   r
   r%   r&   s      r   Útest_single_line_functionz-TestFirstLineFinder.test_single_line_function½   s=   € Ý	Øˆñ 
ŒØå3°CÑ8Ô8ˆØ×!Ò! .°!Ñ4Ô4Ð4Ð4Ð4r   c                 óp   — t           d„ ¦   «         }t          |¦  «        }|                      |d¦  «         d S )Nc                  ó   — dS ©zDocstring
            Nr"   r"   r   r   r#   z/TestFirstLineFinder.test_docstring.<locals>.fooÅ   s	   € ð ˆDr   r5   r%   r&   s      r   Útest_docstringz"TestFirstLineFinder.test_docstringÄ   sF   € Ý	ð	ð 	ñ 
Œð	õ
 4°CÑ8Ô8ˆØ×!Ò! .°!Ñ4Ô4Ð4Ð4Ð4r   c                 óp   — t           d„ ¦   «         }t          |¦  «        }|                      |d¦  «         d S )Nc                  ó   — 	 dS rh   r"   r"   r   r   r#   z1TestFirstLineFinder.test_docstring_2.<locals>.fooÏ   s   € ðàˆDr   r5   r%   r&   s      r   Útest_docstring_2z$TestFirstLineFinder.test_docstring_2Î   sF   € Ý	ð	ð 	ñ 
Œð	õ 4°CÑ8Ô8ˆØ×!Ò! .°!Ñ4Ô4Ð4Ð4Ð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ð 5ð 5ð*ð *ð *ð5ð 5ð 5ð5ð 5ð 5ð*ð *ð *ð>ð >ð >ð,	?ð 	?ð 	?ð?ð ?ð ?ð?ð ?ð ?ð ?ð ?ð ?ð$?ð ?ð ?ð05ð 5ð 5ð5ð 5ð 5ð5ð 5ð 5ð 5ð 5r   r   Ú__main__)ÚunittestrD   r   rX   Únumbar   Únumba.tests.supportr   Únumba.misc.firstlinefinderr   r   rm   Úmainr"   r   r   ú<module>rw      s»   ðØ €€€Ø Ð Ð Ð Ø €€€Ø €€€à Ð Ð Ð Ð Ð Ø (Ð (Ð (Ð (Ð (Ð (Ø AÐ AÐ AÐ AÐ AÐ AðN5ð N5ð N5ð N5ð N5˜(ñ N5ô N5ð N5ðb ˆzÒÐØ€H„M�O„O€O€O€Oð Ðr   