B
     \
                 @   s\   d dl mZ d dlmZ d dlmZmZmZmZ d dl	m
Z
 ddlmZ G dd deZd	S )
    )print_function)Pipeline)jitgenerated_jittypesobjmode)
FunctionIR   )TestCasec                   s4   e Zd Z fddZdd Zdd Zdd Z  ZS )	TestCustomPipelinec                s,   t t|   G  fdddt  | _d S )Nc                   s0   e Zd Zg Z fddZ fddZ  ZS )z0TestCustomPipeline.setUp.<locals>.CustomPipelinec                s   | j | t | |S )N)custom_pipeline_cacheappendsupercompile_extra)selffunc)CustomPipeline	__class__ 8lib/python3.7/site-packages/numba/tests/test_pipeline.pyr      s    z>TestCustomPipeline.setUp.<locals>.CustomPipeline.compile_extrac                s$   | j | t | j|f||S )N)r   r   r   
compile_ir)r   Zfunc_irargskwargs)r   r   r   r   r      s    
z;TestCustomPipeline.setUp.<locals>.CustomPipeline.compile_ir)__name__
__module____qualname__r   r   r   __classcell__r   )r   )r   r   r      s   r   )r   r   setUpr   pipeline_class)r   )r   )r   r   r   
   s    zTestCustomPipeline.setUpc             C   sL   |  | jjg  t| jddd }| |dd |  | jj|jg d S )N)r   c             S   s   | S )Nr   )xr   r   r   foo!   s    z8TestCustomPipeline.test_jit_custom_pipeline.<locals>.foo   )assertListEqualr   r   r   assertEqualpy_func)r   r    r   r   r   test_jit_custom_pipeline   s
    
z+TestCustomPipeline.test_jit_custom_pipelinec                sV   |  | jjg  dd  t| jd fdd}| |dd |  | jj g d S )Nc             S   s   | S )Nr   )r   r   r   r   inner,   s    zDTestCustomPipeline.test_generated_jit_custom_pipeline.<locals>.inner)r   c                s   t | tjr S d S )N)
isinstancer   ZInteger)r   )r&   r   r   r    /   s    zBTestCustomPipeline.test_generated_jit_custom_pipeline.<locals>.foo   )r"   r   r   r   r#   )r   r    r   )r&   r   "test_generated_jit_custom_pipeline)   s    
z5TestCustomPipeline.test_generated_jit_custom_pipelinec             C   s   |  | jjg  t| jddd }d}| |||d  | t| jjd | jjd }| ||j | jjd }| |t	 d S )N)r   c          	   S   s&   t dd | td7 } W d Q R X | S )NZintp)r   r	   )r   int)r   r   r   r   r    ;   s    z<TestCustomPipeline.test_objmode_custom_pipeline.<locals>.foo{   r	      r   )
r"   r   r   r   r#   lenZassertIsr$   ZassertIsInstancer   )r   r    argfirstsecondr   r   r   test_objmode_custom_pipeline8   s    z/TestCustomPipeline.test_objmode_custom_pipeline)r   r   r   r   r%   r)   r1   r   r   r   )r   r   r   	   s   r   N)Z
__future__r   Znumba.compilerr   Znumbar   r   r   r   Znumba.irr   Zsupportr
   r   r   r   r   r   <module>   s
   