U
    9%e                     @   s   d dl mZ d dlmZ d dlmZmZmZmZm	Z	m
Z
 d dlmZmZmZmZmZmZmZmZmZmZmZ ed\Z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 )    )symbols)ccode)DeclarationVariablefloat64int64String	CodeBlock)alignofCommaOperatorgotoLabelPreDecrementPostDecrementPreIncrementPostIncrementsizeofunionstructzx yc                  C   s0   t t} t| dkst| j| j | ks,td S )Nz
alignof(x))r
   xr   AssertionErrorfuncargs)Zax r   ^/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/sympy/codegen/tests/test_cnodes.pytest_alignof   s    r   c                  C   s:   t ttdt } t| dks"t| j| j | ks6td S )N   z(++(x), 2*x))r   r   r   r   r   r   r   )exprr   r   r   test_CommaOperator   s    r   c                  C   s$  d} t | }|j|j |ks t|t dks0tt|dks@tt| }t|dksXt|tdksht|tdksxtttg}t| |}|jt	dkst|j
tttkstt|dkstttttg}t| |}|jt	dkst|j
tttttkstt|dks td S )NZ
early_exitZfoobarzgoto early_exitzearly_exit:zearly_exit:
++(x);z#early_exit:
{
   ++(x);
   --(y);
})r   r   r   r   r   r   r   r   namer   bodyr	   r   y)sgl1r    l2r   r   r   test_goto_Label   s&    


r&   c                  C   s0   t t} | j| j | kstt| dks,td S )Nz--(x))r   r   r   r   r   r   pr   r   r   test_PreDecrement3   s    r)   c                  C   s0   t t} | j| j | kstt| dks,td S )Nz(x)--)r   r   r   r   r   r   r'   r   r   r   test_PostDecrement9   s    r*   c                  C   s0   t t} | j| j | kstt| dks,td S )Nz++(x))r   r   r   r   r   r   r'   r   r   r   test_PreIncrement?   s    r+   c                  C   s0   t t} | j| j | kstt| dks,td S )Nz(x)++)r   r   r   r   r   r   r'   r   r   r   test_PostIncrementE   s    r,   c                  C   s^   d} t | }t|d|  ks t|j|j |ks4t|jr>t| tdtdhksZtd S )Nzunsigned intz
sizeof(%s)r   )r   r   r   r   r   Zis_AtomZatomsr   )typenameszr   r   r   test_sizeofK   s    
r/   c                  C   s   t ttdt ttd } }td| |g}|j|j |ks<t|td| |fksRt|td|| fkshtt|j	dksztt
|jdksttdd |jD stt|dkstd S )NtypeZvec2r   c                 s   s   | ]}t |tV  qd S N
isinstancer   .0argr   r   r   	<genexpr>\   s     ztest_struct.<locals>.<genexpr>z)struct vec2 {
   double x;
   double y;
})r   r   r   r!   r   r   r   r   strr   lendeclarationsallr   )vxvyr"   r   r   r   test_structT   s    r?   c                  C   s   t ttdt ttd } }td| |g}|j|j |ks<t|td| |fksRtt	|j
dksdtt|jdksvttdd |jD stt|dkstd S )Nr0   Zdualuser   c                 s   s   | ]}t |tV  qd S r2   r3   r5   r   r   r   r8   k   s     ztest_union.<locals>.<genexpr>z,union dualuse {
   double x;
   int64_t y;
})r   r   r   r!   r   r   r   r   r   r9   r   r:   r;   r<   r   )r=   r>   ur   r   r   
test_uniond   s    rA   N)#Zsympy.core.symbolr   Zsympy.printing.codeprinterr   Zsympy.codegen.astr   r   r   r   r   r	   Zsympy.codegen.cnodesr
   r   r   r   r   r   r   r   r   r   r   r   r!   r   r   r&   r)   r*   r+   r,   r/   r?   rA   r   r   r   r   <module>   s    4	