U
    Ã9%e@  ã                   @   sX   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„ deƒZe	dkrTe  
¡  dS )é    N©Únjit)Ú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   Úcaller_frame© r   ú_/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/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   2   s    zBTestFirstLineFinder.test_nested_function.<locals>.foo.<locals>.foor   )r   r   r   r   r   1   s    
z5TestFirstLineFinder.test_nested_function.<locals>.fooé   )r   r   )r   r   Úinnerr   r   r   r   Útest_nested_function0   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_evalE   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   S   s    z:TestFirstLineFinder.test_single_line_function.<locals>.foor   r   r   r   r   r   Útest_single_line_functionR   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   Z   s    z/TestFirstLineFinder.test_docstring.<locals>.foor&   r   r   r   r   r   Útest_docstringY   s    
z"TestFirstLineFinder.test_docstringc                 C   s$   t dd„ ƒ}t|ƒ}|  |d¡ d S )Nc                   S   s   dS r/   r   r   r   r   r   r   d   s    z1TestFirstLineFinder.test_docstring_2.<locals>.foor&   r   r   r   r   r   Útest_docstring_2c   s    
z$TestFirstLineFinder.test_docstring_2N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r!   r%   r(   r)   r-   r.   r0   r1   r   r   r   r   r   	   s   	
r   Ú__main__)Zunittestr   Znumbar   Znumba.tests.supportr   Znumba.misc.firstlinefinderr   r   r2   Úmainr   r   r   r   Ú<module>   s   h