U
    {±Ëhó  ã                   @   sB   d dl Z d dlmZ d dlmZmZmZmZ G dd„ de jƒZ	dS )é    N)ÚShadow)ÚOptionsÚCythonScopeÚ
PyrexTypesÚErrorsc                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
Ú
TestShadowc           
      C   sô   g }g }t j ¡ D ]Ä}| d¡}|d |dd …  }}t j |¡}|rtt|ƒdkrt|d dkrttt|ƒr| 	|¡ q|dkr~q|dkrˆqtt|ƒsž| 	|¡ q|rt
t|ƒ}|D ]$}	tt|ƒdƒsÐtt|ƒdƒr° qq°q|  |g ¡ |  |g ¡ d S )	NÚ.r   é   ÚmoduleZcollection_typeÚstaticmethodÚ__getattr__Ú__getattribute__)r   Zdirective_typesÚkeysÚsplitZdirective_scopesÚgetÚlenÚhasattrr   ÚappendÚgetattrÚtypeÚassertEqual)
ÚselfZmissing_directivesZextra_directivesZfull_directiveZsplit_directiveÚ	directiveÚrestZscopeZdirective_valueZsubdirective© r   ú;/tmp/pip-unpacked-wheel-fhl22ezh/Cython/Tests/TestShadow.pyÚtest_all_directives_in_shadow   s2    




ÿz(TestShadow.test_all_directives_in_shadowc                 C   sb   t  d ¡}g }|j ¡ D ]8}| d¡r2| d¡r2q|dkr<qtt|ƒs| |¡ q|  	|g ¡ d S )NÚ__)ZPyTypeObjectZPyObject_TypeCheck)
r   Úcreate_cython_scopeÚentriesr   Ú
startswithÚendswithr   r   r   r   )r   Úcython_scopeÚmissing_typesÚkeyr   r   r   Útest_all_types_in_shadow*   s    

z#TestShadow.test_all_types_in_shadowc                 C   s´   g }t jD ]˜}dD ]Ž}|| }|rX|dks2|dkrX|  |tt ƒ¡ |  d| tt ƒ¡ qtt |ƒsl| |¡ tddƒD ](}d| d | }tt |ƒsv| |¡ qvqq
|  |g ¡ d S )	N)Ú ÚuÚs)Z
Py_UNICODEZPy_UCS4Z
Py_ssize_tZssize_tZ	ptrdiff_tZ	Py_hash_tZusize_tZp_r	   é   ÚpÚ_)r   Ú	int_typesZassertNotInÚdirr   r   Úranger   )r   r#   Zint_nameÚsignÚnameÚptrÚptr_namer   r   r   Útest_int_types_in_shadow<   s&    
ÿý


z#TestShadow.test_int_types_in_shadowc                 C   sÞ   t  d ¡}G dd„ dƒ}||_t ¡  g }g }tj ¡ D ]ˆ\\}}}}|dkrPq8tt	|ƒsd| 
|¡ | |¡sx| 
|¡ tddƒD ]<}	d|	 d | }
tt	|
ƒsª| 
|
¡ | |
¡s‚| 
|
¡ q‚q8|  |g ¡ |  |g ¡ d S )Nc                   @   s   e Zd ZdZdZg ZdS )z+TestShadow.test_most_types.<locals>.ContextFé   N)Ú__name__Ú
__module__Ú__qualname__ÚcppZlanguage_levelZfuture_directivesr   r   r   r   ÚContext[   s   r9   Úobjectr	   r)   r*   r+   )r   r   Ú_contextr   Zinit_threadr   Zmodifiers_and_name_to_typeÚitemsr   r   r   Zlookup_typer.   r   )r   r"   r9   r#   Zmissing_lookupsÚsignedZlongnessr0   Útype_r1   r2   r   r   r   Útest_most_typesU   s*    







zTestShadow.test_most_typesN)r5   r6   r7   r   r%   r3   r?   r   r   r   r   r      s   #r   )
ZunittestZCythonr   ZCython.Compilerr   r   r   r   ZTestCaser   r   r   r   r   Ú<module>   s   