U
    ?h@                     @   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   Zcaller_frame r   R/var/www/html/venv/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_firstlinenoZ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,   r.   r/   r   r   r   r   r   	   s   	
r   __main__)Zunittestr   Znumbar   Znumba.tests.supportr   Znumba.misc.firstlinefinderr   r   r0   mainr   r   r   r   <module>   s   h