U
    ,‰d!  ã                   @   sd   d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm	Z	 G dd„ deƒZ
edkr`e  ¡  dS )	é    N©Únjit)Ú	PYVERSION)ÚTestCase)Úget_func_body_first_linenoc                   @   sh   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zd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                 C   s   t  ¡ }t  |¡}|d jjS )Né   )ÚinspectÚcurrentframeÚgetouterframesÚframeÚf_code)Úselfr   Zcaller_frame© r   úD/tmp/pip-unpacked-wheel-eu7e0c37/numba/tests/test_firstlinefinder.pyÚ_get_grandparent_caller_code   s    
z0TestFirstLineFinder._get_grandparent_caller_codec                 C   s"   |   ¡ }|j}|  ||| ¡ d S ©N)r   Úco_firstlinenoÚassertEqual)r   ÚexpectedZoffset_from_callerZgrandparent_coÚlnor   r   r   Úassert_line_location   s    z(TestFirstLineFinder.assert_line_locationc                 C   s$   t dd„ ƒ}t|ƒ}|  |d¡ d S )Nc                   S   s   dS ©Né   r   r   r   r   r   Úfoo   s    zBTestFirstLineFinder.test_decorated_odd_comment_indent.<locals>.fooé   ©r   r   r   ©r   r   Úfirst_def_liner   r   r   Ú!test_decorated_odd_comment_indent   s    
z5TestFirstLineFinder.test_decorated_odd_comment_indentc                 C   s$   dd„ }t t|ƒƒ}|  |d¡ d S )Nc                   S   s   dS r   r   r   r   r   r   r   $   s    zDTestFirstLineFinder.test_undecorated_odd_comment_indent.<locals>.fooé   )r   r   r   r   r   r   r   Ú#test_undecorated_odd_comment_indent#   s    z7TestFirstLineFinder.test_undecorated_odd_comment_indentc                 C   s"   dd„ }t t|ƒƒ}|  |¡ d S )Nc                   S   s   dS r   r   r   r   r   r   Ú<lambda>,   ó    z9TestFirstLineFinder.test_unnamed_lambda.<locals>.<lambda>)r   r   ÚassertIsNoner   r   r   r   Útest_unnamed_lambda+   s    z'TestFirstLineFinder.test_unnamed_lambdac                 C   s&   dd„ }|ƒ }t |ƒ}|  |d¡ d S )Nc                  S   s   t dd„ ƒ} | S )Nc                   S   s   dS r   r   r   r   r   r   r   3   s    zBTestFirstLineFinder.test_nested_function.<locals>.foo.<locals>.foor   )r   r   r   r   r   2   s    
z5TestFirstLineFinder.test_nested_function.<locals>.fooé   )r   r   )r   r   Úinnerr   r   r   r   Útest_nested_function1   s    z(TestFirstLineFinder.test_nested_functionc                 C   s$   t dd„ ƒ}t|ƒ}|  |d¡ d S )Nc                   S   s   d S r   r   r   r   r   r   r   ?   s    z4TestFirstLineFinder.test_pass_statement.<locals>.foor    r   r   r   r   r   Útest_pass_statement>   s    
z'TestFirstLineFinder.test_pass_statementc                 C   s0   d}i }t ||ƒ |d }t|ƒ}|  |¡ d S )Nz$def foo():
            pass
        r   )Úexecr   r$   )r   ÚsourceÚglobalnsr   r   r   r   r   Útest_string_evalF   s    
z$TestFirstLineFinder.test_string_evalc                 C   s$   t dd„ ƒ}t|ƒ}|  |d¡ d S )Nc                   S   s   d S r   r   r   r   r   r   r   T   s    z:TestFirstLineFinder.test_single_line_function.<locals>.foor   r   r   r   r   r   Útest_single_line_functionS   s    
z-TestFirstLineFinder.test_single_line_functionc                 C   s$   t dd„ ƒ}t|ƒ}|  |d¡ d S )Nc                   S   s   dS ©zDocstring
            Nr   r   r   r   r   r   [   s    z/TestFirstLineFinder.test_docstring.<locals>.foor&   r   r   r   r   r   Útest_docstringZ   s    
z"TestFirstLineFinder.test_docstringc                 C   s:   t dd„ ƒ}t|ƒ}tdkr*|  |d¡ n|  |d¡ d S )Nc                   S   s   dS r/   r   r   r   r   r   r   e   s    z1TestFirstLineFinder.test_docstring_2.<locals>.foo)r    é   é   r&   )r   r   r   r   r   r   r   r   Útest_docstring_2d   s    
z$TestFirstLineFinder.test_docstring_2N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r!   r%   r(   r)   r-   r.   r0   r3   r   r   r   r   r   
   s   	
r   Ú__main__)Zunittestr	   Znumbar   Znumba.core.utilsr   Znumba.tests.supportr   Znumba.misc.firstlinefinderr   r   r4   Úmainr   r   r   r   Ú<module>   s   l