a
    b                     @   sb   d dl mZ d dlT d dlT d dlT d dlm  mZ G dd deZe	dkr^d dl
Z
e
  dS )    )
CythonTest)*Nc                   @   sD   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S )TestTreeFragmentsc                 C   s"   |  d}| }| d| d S )Nx = 4)fragmentcopy
assertCode)selfFT r   v/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-packages/Cython/Compiler/Tests/TestTreeFragment.py
test_basic	   s    
zTestTreeFragments.test_basicc                 C   sn   |  d}|j}| }| d|jd jd jjj d|jd jd jj_| d|jd jd jjj d S )Nzif True: x = 4xr   other)	r   rootr   assertEqualstatsZ
if_clausesbodylhsname)r	   r
   ZT1ZT2r   r   r   test_copy_is_taken   s    
z$TestTreeFragments.test_copy_is_takenc                 C   sr   |  ddtd ddi}| d|jd jjj | d|jd jjj | 	|jd jj|jd jju d S )Nzy + yyr   posr   r   )
r   
substituteNameNoder   r   exproperand1r   operand2
assertTrue)r	   r   r   r   r   test_substitutions_are_copied   s    z/TestTreeFragments.test_substitutions_are_copiedc                 C   s4   |  d}td dd}|d|i}| d| d S )Nr   r   r   r   zy = 4)r   r   r   r   )r	   r
   r   r   r   r   r   test_substitution   s    
z#TestTreeFragments.test_substitutionc                 C   s>   |  d}td d}|d|i}| t|jd t| d S )NZPASS)r   r   )r   ZPassStatNoder   r    
isinstancer   )r	   r
   Z	pass_statr   r   r   r   test_exprstat"   s    

zTestTreeFragments.test_exprstatc                 C   sV   |  d}|dtd ddi}|jjd jjj}|jd jjj}| |j	|j	 d S )Nz.
        x = y
        x = u * v ** w
        var      )
r   r   r   r   r   rhsr   r   r   r   )r	   r
   r   r%   r&   r   r   r   test_pos_is_transferred(   s
    
z)TestTreeFragments.test_pos_is_transferredc                 C   st   dt _| d}|jdgd}|jj}| t|d jt	 | t|d j
t	 | |d jj|d j
ju  d S )Nr   z-
            TMP
            x = TMP
        TMP)Ztempsr'   )ZTemplateTransformZtemp_name_counterr   r   r   r   r    r#   r   ZTempRefNoder(   handle)r	   r
   r   sr   r   r   
test_temps2   s    
zTestTreeFragments.test_tempsN)
__name__
__module____qualname__r   r   r!   r"   r$   r)   r-   r   r   r   r   r      s   
r   __main__)ZCython.TestUtilsr   ZCython.Compiler.TreeFragmentZCython.Compiler.NodesZCython.Compiler.UtilNodesZCython.Compiler.NamingZCompilerZNamingr   r.   Zunittestmainr   r   r   r   <module>   s   7