U
    L?h4.                     @   s   d dl mZ d dlmZ d dlmZ edZerd dlmZm	Z	m
Z
mZmZmZmZmZmZ d dlmZmZmZ d dlmZ e Z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"ndd Z#dS )    )raisesSymPyExpression)import_modulelfortran)	VariableIntBaseTypeFloatBaseTypeStringReturnFunctionDefinition
AssignmentDeclaration	CodeBlock)IntegerFloatAdd)Symbolz5    integer :: a, b, c, d
    real :: p, q, r, s
    c                  C   s$  t d } tt d}t| d}| }| }tddD ](}t|| tsLtt|| ts6tq6t|d tsrt|d ttt	dt
tdtddkst|d	 ttt	d
t
tdtddkst|d ttt	dt
tdtddkst|d ttt	dt
tdtddks,t|d ttt	dttdtddks\t|d ttt	dttdtddkst|d ttt	dttdtddkst|d ttt	dttdtddkst|d ttt	dt	dt	d
 t	d ks td S )Nz%            d = a + b -c
            fr         aintegertypevalue   b   c   d   preal           q   rs)srcr   return_exprrange
isinstancer   AssertionErrorr   r   r   r   r
   r   r	   r   )src1Zexpr3Zexpr4ls1Zls2i r3   Y/var/www/html/venv/lib/python3.8/site-packages/sympy/parsing/tests/test_fortran_parser.pytest_sym_expr   s    













r5   c                  C   s   t d } t| d t }tddD ]2}|dk rFt|| tsXtq&t|| ts&tq&|d tt	t
dt	t
dkst|d tt	t
d	t	t
d
kst|d tt	t
dt	t
dkst|d tt	t
dt	t
dkstd S )NzT            a = b
            c = d
            p = q
            r = s
            r   r      r   r   r   	   r   r!   
   r#   r'      r)   r*   )r+   expr1convert_to_exprr,   r-   r.   r   r/   r   r   r   r0   r1   iterr3   r3   r4   test_assignmentc   s4    	










r>   c                  C   s   t d } t| d t }tddD ]}t|| ts&tq&|d ttt	dt	dt	d ksht|d ttt	d	t	dt	d kst|d
 ttt	dt	dt	d t	d kstd S )NzR            c = a + b
            d = a + c
            s = p + q + r
            r   r   r9   r   r   r   r7   r!   r8   r*   r#   r'   r)   
r+   r:   r;   r,   r-   r.   r   r/   r   r   r<   r3   r3   r4   test_binop_add   s(    




r@   c                  C   s   t d } t| d t }tddD ]}t|| ts&tq&|d ttt	dt	dt	d ksht|d ttt	d	t	dt	d kst|d
 ttt	dt	dt	d t	d kstd S )NzR            c = a - b
            d = a - c
            s = p - q - r
            r   r   r9   r   r   r   r7   r!   r8   r*   r#   r'   r)   r?   r<   r3   r3   r4   test_binop_sub   s(    




rA   c                  C   s   t d } t| d t }tddD ]}t|| ts&tq&|d ttt	dt	dt	d ksht|d ttt	d	t	dt	d kst|d
 ttt	dt	dt	d t	d kstd S )NzR            c = a * b
            d = a * c
            s = p * q * r
            r   r   r9   r   r   r   r7   r!   r8   r*   r#   r'   r)   r?   r<   r3   r3   r4   test_binop_mul   s(    




rB   c                  C   s   t d } t| d t }tddD ]}t|| ts&tq&|d ttt	dt	dt	d ksht|d ttt	d	t	dt	d kst|d
 ttt	dt	dt	d kst|d ttt	dt	dt	d kstd S )Nzd            c = a / b
            d = a / c
            s = p / q
            r = q / p
            r   r   r6   r   r   r   r7   r!   r8   r*   r#   r'   r9   r)   r?   r<   r3   r3   r4   test_binop_div   s0    	






rC   c                  C   s  t d } t| d t }tddD ]}t|| ts&tq&|d ttt	dt	dt	d t	d kspt|d	 ttt	dt	dt	d t	d kst|d
 ttt	dt	dt	d t	d kst|d ttt	dt	dt	d t	dt	d  kstd S )Nzx            d = a + b - c
            c = a * b + d
            s = p * q / r
            r = p * s + q / p
            r   r   r6   r!   r   r   r   r7   r8   r*   r#   r'   r)   r9   r?   r<   r3   r3   r4   test_mul_binop   s0    	






rD   c                  C   s8  d} t | d t  D ]}t|ts,t|tttdtdtt	dtt	dft
ttt	dttdtddttt	dttdtddttt	dttdtddttt	dttdtddttt	d	ttdtddttt	dtt	dt	d	ttt	dd
kstqd S )Nzg        integer function f(a,b)
        integer :: x, y
        f = x + y
        end function
        r   r   r   r   r   r   xy)name
parametersbody)r:   r;   r,   r.   r   r/   r   r
   r   r   r   r   r   r   r   r   )r0   r=   r3   r3   r4   test_function  sj    








rJ   c                  C   s  t td t  } t  D ]}t|tstq| d tttdt	t
dtddks^t| d tttdt	t
dtddkst| d tttd	t	t
dtddkst| d
 tttdt	t
dtddkst| d tttdtt
dtddkst| d tttdtt
dtddksHt| d tttdtt
dtddksxt| d tttdtt
dtddkstd S )Nr   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r   r*   )r:   r;   r+   r,   r.   r   r/   r   r   r   r
   r   r	   r   )Zlsr=   r3   r3   r4   test_varT  sx    











rK   c                      s0   ddl m  tt fdd ttdd  d S )Nr   ASR2PyVisitorc                      s     S )Nr3   r3   rL   r3   r4   <lambda>      ztest_raise.<locals>.<lambda>c                   S   s   t dddS )N r   )moder   r3   r3   r3   r4   rN     rO   )Z$sympy.parsing.fortran.fortran_parserrM   r   ImportErrorr3   r3   rL   r4   
test_raise  s    rS   N)$Zsympy.testing.pytestr   Zsympy.parsing.sym_exprr   Zsympy.externalr   r   Zsympy.codegen.astr   r   r	   r
   r   r   r   r   r   Z
sympy.corer   r   r   Zsympy.core.symbolr   r:   Zexpr2r+   r5   r>   r@   rA   rB   rC   rD   rJ   rK   rS   r3   r3   r3   r4   <module>   s(   ,L# >
?