Your IP : 216.73.216.85


Current Path : /opt/alt/python38/lib64/python3.8/test/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/test/__pycache__/test_numeric_tower.cpython-38.pyc

U

i�f��@s�ddlZddlZddlZddlZddlZddlmZddlm	Z
ejjZ
ejjZGdd�dej�ZGdd�dej�Zedkr�e��dS)	�N)�Decimal)�Fractionc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�HashTestcCs.|�t|�t|�d�||��|�||�dS)Nz&got different hashes for {!r} and {!r})�assertEqual�hash�format)�self�x�y�r�</opt/alt/python38/lib64/python3.8/test/test_numeric_tower.py�check_equal_hashs
�zHashTest.check_equal_hashcCs|�dd�|�dd�dS)NFrT�)r
�rrrr�
test_boolsszHashTest.test_boolscCs�tdd�D]4}|�|t|��|�|t|��|�|t|��q
td�D�]}d|d}|tt|��kr�|�|t|��|�|t|��|�|t|��|�|t|��|�|t|��|�|t|��d|}|�|t|��|�|t|��|�|t|��|�|t|��|�|t|��|�|t|��qHtd�D]h}t�d�}t�d|d|�}|�|t|��|�|t|��|tt|��k�rT|�|t|���qTdS)Ni������d�ri,�
)�ranger
�float�D�F�int�randomZ	randrange)r�i�n�_�errr�
test_integerss6
zHashTest.test_integerscCs�|�dd�|�dtd��|�dtd��|�dtd��|�dtd��|�td�td��|�td�td��td�D]F}t��t�t��dd	�}|�|t�|��|�|t�|��q|dS)
N���rz-0.0�inf�-infrgi@gY@)	r
rrrrr�mathZexpZ
from_float)rrr	rrr�test_binary_floatsBszHashTest.test_binary_floatsc	CsFddddddtd�td�g}d	D] }|D]}|�|t||��q(q dS)
Nr r!��?g�g�?g���r"r#)r!r )rr
�complex)r�test_values�zero�valuerrr�test_complexWs�zHashTest.test_complexcCs�dddddg}|D]}|�t|�td��q|�td�td��|�td	�td��|�td
�td��|�td�td��|�td
�td��|�td�td��|�td�td��|�td�td��|�td�td��|�td�td��dS)N�0z-0z0.0z-0.0e10z000e-10rz1.00rz1.00000z-1.00���z-1.00000Z123e2i0Z1230e1Z12300z12300.0z12300.00z	12300.000)r
r)rZzerosr)rrr�
test_decimalsbszHashTest.test_decimalscCsh|�ttdt��t�|�ttddt��t�|�ttdtd��d�|�tttd��d�dS)Nrr-��r)rrr�_PyHASH_MODULUS�_PyHASH_INFrrrr�test_fractionstszHashTest.test_fractionscCs,Gdd�d�}d|�h}|�t|�d�dS)Nc@seZdZdd�Zdd�ZdS)z6HashTest.test_hash_normalization.<locals>.HalibutProxycSstd�S�N�halibut)rrrrr�__hash__�sz?HashTest.test_hash_normalization.<locals>.HalibutProxy.__hash__cSs|dkSr4r)r�otherrrr�__eq__�sz=HashTest.test_hash_normalization.<locals>.HalibutProxy.__eq__N)�__name__�
__module__�__qualname__r6r8rrrr�HalibutProxy�sr<r5r)r�len)rr<r	rrr�test_hash_normalization|s
z HashTest.test_hash_normalizationN)r9r:r;r
rrr%r+r.r3r>rrrrrs&rc@seZdZdd�Zdd�ZdS)�ComparisonTestcCs�td�td�dtdd�dddd	d
td�td�td
�tdd�td�tdd�tdd�dtd�g}t|�D]N\}}||dd�D]4}|�||�|�||�|�||�|�||�q|qddS)Nr#z-1e425000000g������i��r0g��Q�	����r g�Tz1.2z1.3z1.4i_5i�z1.414213562373095048801688724iC�i�;i��:i�Jgvܼ5J�iZinfinityr)rrr�	enumerateZ
assertLessZassertLessEqualZ
assertGreaterZassertGreaterEqual)rr(r�first�secondrrr�test_mixed_comparisons�s2�z%ComparisonTest.test_mixed_comparisonscCsd}d}ddtd�td�td�fD]}|�||�|�||�q"ddtd�td�td�fD]4}|�||�|�||�|�||�|�||�qZddtd�td�td�ddtd�td�td�|fD]>}tjtjtjtj	fD]$}|�
t|||�|�
t|||�q�q�dS)Ny�?y��Q�	�������@rr&rg@)rrr'rZassertNotEqual�operator�le�lt�ge�gtZassertRaises�	TypeError)r�z�w�v�oprrrr+�s*�zComparisonTest.test_complexN)r9r:r;rDr+rrrrr?�sr?�__main__)Zunittestrr$�sysrE�decimalrrZ	fractionsrr�	hash_info�modulusr1r"r2ZTestCaserr?r9�mainrrrr�<module>s8