o
    '[h                     @   s~   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 zd dl	Z	dZ
W n   dZ
Y edddZdZG d	d
 d
eZdS )    N)inline)	safe_type)
CythonTestTF)forcequietd   c                   @   s   e 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d Zee ddd ZdS )
TestInlinec                 C   sJ   t |  tt| _tjdrtjdd}nt	j
dd}|| jd< d S )NTEST_TMPr   cython_inline_)prefixlib_dir)r   setUpdict	test_kwds
_call_kwdsospathisdirjointempfilemkdtemp)selfr    r   R/var/www/vscode/pina/lib/python3.10/site-packages/Cython/Build/Tests/TestInline.pyr      s   

zTestInline.setUpc                 C   s   |  tdi | jd d S )N
return 1+2   )r   assertEqualr   r   r   r   r   r   test_simple   s   zTestInline.test_simplec                 C   s"   |  tddg d| jd d S )NZ
            cimport cython
            return cython.typeof(a), cython.typeof(b)
        g      ?)ab)doublezlist object)r    r   r   r   r   r   
test_types   s   zTestInline.test_typesc                 C   s$   d}d}|  tdi | jd d S )N      
return a+br   )r'   r   )r   r!   r"   r   r   r   test_locals%   s   zTestInline.test_localsc                 C   s    |  tdi | jtd  d S )Nreturn global_value + 1r%   )r)   )r   r   r   global_valuer   r   r   r   test_globals*   s    zTestInline.test_globalsc                 C   s&   |  tdi | jtddg d d S )NQ
            a = 1
            cdef double b = 2
            cdef c = []
        r%   g       @)r!   r"   c)r,   )r   r   r   r   r   r   r   r   test_no_return-   s
   
zTestInline.test_no_returnc                 C   s(   t di | jd }| |dd d S )Ndef foo(x): return x * xfoo   1   )r/   )r   r   r   )r   r0   r   r   r   test_def_node4   s   zTestInline.test_def_nodec                 C   s,   G dd dt }tdd }| || d S )Nc                   @   s   e Zd ZdS )z'TestInline.test_class_ref.<locals>.TypeN)__name__
__module____qualname__r   r   r   r   Type9   s    r7   )objectr   r   )r   r7   tpr   r   r   test_class_ref8   s   zTestInline.test_class_refc                 C   s0   dd l }tdddi| j}| t|t d S )Nr   l
        b = cy.declare(float, a)
        c = cy.declare(cy.pointer(cy.float), &b)
        return b
        r!   r   )r;   )cythonr   r   r   typefloat)r   cyr"   r   r   r   	test_pure>   s   zTestInline.test_purec                 C   s"   |  tdg dddidd d S )Nzreturn sum(x))r%   r&   r   boundscheckF)xcython_compiler_directives   r   r   r   r   r   r   test_compiler_directivesG   s   z#TestInline.test_compiler_directivesc                 C   sb   d}|  t|ddd ddd |  t|ddd ddd |  t|ddd ddd d S )Nzdef f(int a, int b): return a/br&   )language_levelf   r   g      @rE   )r   inline_divcoder   r   r   test_lang_versionO   s   zTestInline.test_lang_versionc                 C   s   d}|  t|d ddd |  t|d ddd |  t|d ddd	 |  t|d ddd t|d }|  |ddd |  |ddd d S )
Nz!def f(int a, int b): return a * brH   rI   r&   
   r      rD      rE   )r   inline_mulcoderH   r   r   r   test_repeated_use_   s   zTestInline.test_repeated_usezNumPy is not availablec                 C   sJ   dd l }|d}d|d< | t|d | td	d|i| jd d S )
Nr   )rL      rL   )r   r   z&numpy.ndarray[numpy.float64_t, ndim=2]return a[0,0]r!   g      $@)rR   )numpyndarrayr   r   r   r   )r   rS   r!   r   r   r   
test_numpyj   s
   
 zTestInline.test_numpyN)r4   r5   r6   r   r   r$   r(   r+   r.   r3   r:   r@   rF   rK   rP   unittestskipIf	has_numpyrU   r   r   r   r   r      s    		r   )r   r   rV   Cython.Shadowr   Cython.Build.Inliner   Cython.TestUtilsr   rS   rX   r   r   r*   r   r   r   r   r   <module>   s    