
    \j                        d Z ddlmZ ddlZddlZddlZddlZddlmZm	Z	 ddl
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mZmZmZmZmZ  G d dej                  ZdS )	zPTest that C functions used in primitives are declared in a header such as CPy.h.    )annotationsN)	HeaderDep	SourceDep)PrimitiveDescription)bytearray_ops	bytes_opsdict_opsexc_ops	float_opsgeneric_opsint_opslibrt_strings_opslibrt_vecs_opslist_opsmisc_opsregistryset_opsstr_ops	tuple_opsweakref_opsc                      e Zd ZddZdS )TestHeaderInclusionreturnNonec                   t           j                            t           j                            t                    dd          }t          t           j                            |d                    5 }|                                d d d            n# 1 swxY w Y   t          t           j                            |d                    5 }|                                z  d d d            n# 1 swxY w Y   dfd	}g }t          j        	                                t          j
        	                                t          j        	                                t          j        	                                fD ]}|D ]}|                    |           t          t          t           t"          t$          t&          t(          t*          t,          t.          t0          t2          t4          t6          t8          fD ]O}t;          |          D ]=}t=          ||d           }	t?          |	t@                    r|!                    |	           >P|D ]}
|
j"        r|
j"        D ]}t?          |tF          tH          f          rt           j                            ||%                                          }t           j        &                    |          r\t          t           j                            ||                    5 }|                                z  d d d            n# 1 swxY w Y   ̌|D ]}
|
j'         ||
j'                   t           j                            t           j                            t                    dd
          }tQ          j(        | d          D ]`}t          |          5 }|                                }d d d            n# 1 swxY w Y   tS          j*        d|          D ]} ||           ad S )Nz..zlib-rtzCPy.hzpythonsupport.hnamestrr   r   c                    |                      d          r't          j        d|  d          sJ d|  d            d S d S )NCPyz\b"z7" is used in mypyc.primitives but not declared in CPy.h)
startswithresearch)r   headers    [/var/www/app.qaans.com/backend/venv/lib/python3.11/site-packages/mypyc/test/test_cheader.py
check_namezJTestHeaderInclusion.test_primitives_included_in_header.<locals>.check_name(   sx    u%% Uy"$NNNF  U UTtTTTU U UU UU U    
primitivesz/*.pyz'c_function_name=["\'](CPy[A-Z_a-z0-9]+))r   r   r   r   )+ospathjoindirname__file__openreadr   method_call_opsvalues
binary_ops	unary_opsfunction_opsextendr   r   r	   r   r   r   r   r   r   r
   r   r   r   r   r   dirgetattr
isinstancer   appenddependenciesr   r   
get_headerisfilec_function_nameglobr"   findall)selfbase_dirfr&   all_opsr1   opsmoduler   valopdepheader_fnamprimitives_pathfnamcontentr$   s                   @r%   "test_primitives_included_in_headerz6TestHeaderInclusion.test_primitives_included_in_header!   s   7<< 9 94JJ"',,x1122 	aVVXXF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	"',,x):;;<< 	affhhF	 	 	 	 	 	 	 	 	 	 	 	 	 	 		U 	U 	U 	U 	U 	U $++--&&((%%''!((**	
 	$ 	$F  $ $s####$ 
 	( 	(F" F ( (fdD11c#788 (NN3'''(  	3 	3B 3? 3 3C!#	9'=>> 3&(gll8S^^=M=M&N&N7>>+66 3!%bgll8[&I&I!J!J 3a &!&&(( 23 3 3 3 3 3 3 3 3 3 3 3 3 3 3  	/ 	/B!-
2-...',,rwx'@'@$UUI77788 	! 	!Dd #q&&((# # # # # # # # # # # # # # #
#MwWW ! !
4    !	! 	!sH   2BBBC//C36C3/LLL'OO	O	N)r   r   )__name__
__module____qualname__rM    r'   r%   r   r       s.        @! @! @! @! @! @!r'   r   )__doc__
__future__r   r>   r)   r"   unittestmypyc.ir.depsr   r   mypyc.ir.opsr   mypyc.primitivesr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   TestCaser   rQ   r'   r%   <module>rY      s`   V V " " " " " "  				 				  . . . . . . . . - - - - - -                                   (A! A! A! A! A!(+ A! A! A! A! A!r'   