Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_long.cpython-310.pyc
o

�9j7��@s*ddlZddlmZddlZddlZddlZddlZejjZ	de	Z
e
dZdZdZ
ddde
e
d?ddgZd	Zede	�D]
Ze�ed�ed>Zq=[ed
d�eD�dd�eD�7ZejjZejjZejjZejjZdedeedZd
d�Zdd�ZGdd�dej�Z e!dkr�e�"�dSdS)�N)�support���F�lUU�*UU�*l�*UU�*UU
�cCsg|]}|�qS�r��.0�xrr�%/usr/lib/python3.10/test/test_long.py�
<listcomp>�r
cC�g|]}|�qSrrr	rrrr
rcCs�tjjd}tjj|}d|>}gd�}|dkrdS|dkr$t|�S|��|}|dkr3||>n||?t|d|>@�B}|||d@7}|||k|krTtd��|d	dkrd|d	dtjjksfJ�|d|tjjksrJ�t	�
t|�|�S)
z9
    Correctly-rounded integer-to-float conversion.

    rr)r������rrrrrr�r�z%integer too large to convert to floatr)�sys�
float_info�mant_dig�max_exp�int_to_float�
bit_length�bool�
OverflowError�max�math�ldexp�float)�n�	PRECISION�	SHIFT_MAX�Q_MAX�ROUND_HALF_TO_EVEN_CORRECTION�shift�qrrrr's ,$rcCs
||Adk}t|�t|�}}|std��|t|krtd��|��|��}|dkr3|d||ks@|dkrD|d||krD|d7}t|t�t}|t|d�>|t|d�>}}t||�\}}d||kstd||krx|ddkrx|d7}t	�
||�}|r�|S|S)z-Correctly-rounded true division for integers.rzdivision by zeroz)int/int too large to represent as a floatrr)�abs�ZeroDivisionError�DBL_MIN_OVERFLOWrrr�DBL_MIN_EXP�DBL_MANT_DIG�divmodrr)�a�b�negative�d�expr&�r�resultrrr�truedivUs 2 $r4c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zejdd ��Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd]d2d3�Zejd4d5��Zd6d7�Zd8d9�Z ej!d:d;��Z"ej!ej#e$j%d<d=d>d?�d@dA���Z&dBdC�Z'ej!ej#e$j%dDdEd>d?�dFdG���Z(ej!dHdI��Z)dJdK�Z*dLdM�Z+dNdO�Z,dPdQ�Z-dRdS�Z.dTdU�Z/dVdW�Z0dXdY�Z1dZd[�Z2d\S)^�LongTestcCs�|�|d�|t}|td}d}d}tt��td�dB}||krb|d?d}t|||�}|�d|ko<tkn�||}||>}|d@rT|d|>dB}tt��td�}||ks$|�||kom|kn�t��dkrz|}|S)Nrrr��?)�
assertGreater�SHIFT�int�random�min�
assertTrue)�self�ndigits�nbits_hi�nbits_lo�answer�nbitsr2�bitsrrr�getran{s(�	zLongTest.getrancCs<d}t|�D]}|t>t�dt�B}qt��dkr|}|S)Nrr6)�ranger8r:�randint�MASK)r>rA�irrr�getran2�szLongTest.getran2c
Cs�|j}|j||d��kt||�\}}||||}}||||}}	|||	d�|||d�|||d�|||||d�|dkrU|�d|koO|knd�n|�||ko`dknd�Wd�dSWd�dS1sxwYdS)N�r�yzmultiplication does not commutez(divmod returns different quotient than /z#divmod returns different mod than %zx != q*y + r after divmodrzbad mod from divmod)�assertEqual�subTestr,r<)
r=rrK�eqr&r2�q2�r2�pab�pbarrr�check_division�s""�	"�zLongTest.check_divisioncCs�ttdtd��ttttd��}|�td�|D]}|�|�}|D]}|�|�p,d}|�||�q$q|�dd�|�dd�|�dd	�|�d
d�|�dd
�|�dd�|�dd�|�dd�|�dd�|�dd�|�dd�|�dd�dS)Nr��l!Us/w��3alZW��3al+Q@{�d��B]Ol�Nl�O�Ol�Nl�t�e�o%g�q�Cgx<l�&�ghrsGlQ5��K�4+�o�-bklC�4+�o�-bkl��.#w�flD�&I-�Xl�Z��nSu9bl�c�v��
��<�Ilrd�FBu�'�pl�PhbIi|�$l1�m�{Wqi���8l�s~5^Fi�y�+l'H�
<{�Cl`<{�Cl�ED_5(�Nl�o�ybal=2zz6l�9�t�m)�listrE�	MAXDIGITS�KARATSUBA_CUTOFF�appendrDrS)r=�digits�lenxr�lenyrKrrr�
test_division�sD�
�������zLongTest.test_divisionc	
Cs�ttdd��ttttd��}|�tdtdg�dd�|D�}|D]I}d|>d}|D]>}||kr5q.|j||d��(d|>d}||}d||>d|>d|>d}|�||�Wd�n1sgwYq.q$dS)Nr��
�dcSsg|]}|t�qSr)r8)r
�digitrrrr
��z+LongTest.test_karatsuba.<locals>.<listcomp>)�abits�bbits)rVrErX�extendrMrL)	r=rZrCrcr-rdr.rrKrrr�test_karatsuba�s2�
�������zLongTest.test_karatsubac	Cs�|j}|j|d��y||d@d�||dB|�||dA|�||d@|�||dBd�||dA|�|||�|||@|�|||B|�|||Ad�|||@d�|||Bd�|||Ad�||d|�|||d�Wd�n1s�wYtdt�D]R}d|}|j|||d��<|||>|?|�|||||?�|||||>�|||@||?|>�|||@||d@�Wd�n1s�wYq�dS)N)rrrrr)rr �p2)rLrMrEr8)r=rrNr rgrrr�check_bitop_identities_1�s:����z!LongTest.check_bitop_identities_1cCs
|j}|j||d��q|||@||@�|||B||B�|||A||A�|||A|A|�|||@||B�|||B||@�|||A||B||@@�|||A||@||@B�|||A||B||B@�Wd�dS1s~wYdS)NrJ�rLrM)r=rrKrNrrr�check_bitop_identities_2s "�z!LongTest.check_bitop_identities_2cCs�|j}|j|||d��N|||@|@|||@@�|||B|B|||BB�|||A|A|||AA�||||B@||@||@B�||||@B||B||B@�Wd�dS1s\wYdS)N)rrK�zri)r=rrKrkrNrrr�check_bitop_identities_3s "�z!LongTest.check_bitop_identities_3c
Cs�tD]}|�|�qtdtd�}|D]*}|�|�}|�|�|D]}|�|�}|�||�|�|||�||d��q!qdS)Nrr)�specialrhrErWrDrjrl)r=rrZr[r\rKrrr�test_bitop_identitiess


��zLongTest.test_bitop_identitiescCs�g}d}|dkrd|}}|r t||�\}}|�t|��|s|��|p(dg}dd|�ddddd�|d�d	d
�|D��S)Nrr�-�0b�0o��0x)r�r_�css�|]}d|VqdS)�0123456789abcdefNr�r
rHrrr�	<genexpr>1s�z'LongTest.slow_format.<locals>.<genexpr>)r,rYr9�reverse�join)r=r�baserZ�signr2rrr�slow_format%s�

��zLongTest.slow_formatc	Cs�dtfdtfdtfdtfdtffD]K\}}||�}|j||jd��|�||�}|�||�Wd�n1s8wY|j|d��|�t	|d�|�Wd�n1sWwYqdS)Nrrtr_ru)r�mapper)�gotr)
�bin�oct�str�repr�hexrM�__name__r}rLr9)r=rr{r~r�expectedrrr�check_format_13s*����zLongTest.check_format_1cCsNtD]}|�|�qtd�D]}tdtd�D]}|�|�}|�|�qqdS)Nr_r)rmr�rErWrD)r=rrHr[rrr�test_format<s
��zLongTest.test_formatc
Csddddfg}|D]4\}}dD]-}dD](}|||}|}|dkr)|tur)|}z
|�t|�|�Wqty<Yqwqq
|�ttd�|�ttd	�|�ttd
�|�ttd�|�ttdd
�|�ttdd�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�td d�d�|�ttd!d�|�ttd"d�d#d$d%d&d'd(d)d*d+d,dd,dg}|D]
}	|�ttd-|	�q�|�ttd.�dS)/N)�100000000000000000000l F�x:^V�e10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000r_r`)rr�+ro)rr� �	z  		  ro�123L�123l�0Lz-37L�0x32Lru�1L���+�000r�0o123�S�0x123i#�0b100rz	 0O123   z 0X123  z 0B100 �0z+0z-0�00�08z-012395is������i�l����������l����l����r�42uこんにちは)�
ValueErrorrLr9�assertRaises)
r=�LL�s�vr|�prefix�ss�vv�
invalid_basesr{rrr�	test_longDsZ
�����zLongTest.test_longcCsBGdd�d�}|�tt|��Gdd�d�}|�t|��d�dS)Nc@�eZdZdd�ZdS)z*LongTest.test_conversion.<locals>.JustLongcS�dS�N�*r�r=rrr�__long__��z3LongTest.test_conversion.<locals>.JustLong.__long__N)r��
__module__�__qualname__r�rrrr�JustLongsr�c@seZdZdd�Zdd�ZdS)z+LongTest.test_conversion.<locals>.LongTrunccSr�r�rr�rrrr��r�z4LongTest.test_conversion.<locals>.LongTrunc.__long__cSr�)N�rr�rrr�	__trunc__�r�z5LongTest.test_conversion.<locals>.LongTrunc.__trunc__N)r�r�r�r�r�rrrr�	LongTrunc�sr�r�)r��	TypeErrorr9rL)r=r�r�rrr�test_conversion}szLongTest.test_conversioncCshzt|�}Wntyd}Ynwzt|�}Wnty#d}Ynwd�|||�}|�|||�dS)N�overflowzAError in conversion of integer {} to float.  Got {}, expected {}.)rrr�formatrL)r=r �actualr��msgrrr�check_float_conversion�s��
�zLongTest.check_float_conversionc

Cs�gd�}|D]}|�t|�|�|�t|�|�qdD]!\}}td�D]}|�ttd|d|��d|d|�q%qdD]!\}}td�D]}|�ttd|d|��d|d|�qIqAtt�}dt}||d}|�t|�t�|�t|d�t�|�t|d�t�|�tt|�|�td|�t�|�tt|�|�tt|d�|�tt|�|�tt|d�|�ttd|d�|�ttd|�|�tt||�td	�D]0}d|d
d}d|d}|�tt|��|�d|d
}d|d}|�tt|��|�q�|d||d|d||d|d||dd|dd|||g}|�|�tdd
�D]}tdd�D]}|�	d|d|��qE�q>|D]}	|�
|	�|�
|	��qXdS)N)rrrl����l����l������l����l�����l)�rr)rr�rUr�rr�r^r)�r��rrtrrr�))rrr�)rrr�r�r�)r�rtr�)rtrt)�	rt)r_rt)��)r�r�)�
r�)rTru)rrur�rr`lr����rt�����5)rLrrEr9�DBL_MAX�DBL_MAX_EXPr�rrerYr�)
r=�exact_valuesrrK�p�int_dbl_max�	top_power�halfway�test_values�valuerrr�test_float_conversion�s`
.�.��
�
�zLongTest.test_float_conversioncCsrdD]}|�tt|��|�qd}dd>}|}|||td�}dD]
}|�tt||�q!|�t|�t|�d�dS)N)g���r��?�@�X123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345123451234512345ri0u)�huge�mhuge�shuger)$�float(huge)�float(mhuge)z
complex(huge)zcomplex(mhuge)zcomplex(huge, 1)zcomplex(mhuge, 1)zcomplex(1, huge)zcomplex(1, mhuge)z	1. + hugez	huge + 1.z
1. + mhugez
mhuge + 1.z	1. - hugez	huge - 1.z
1. - mhugez
mhuge - 1.z	1. * hugez	huge * 1.z
1. * mhugez
mhuge * 1.z
1. // hugez
huge // 1.z1. // mhugezmhuge // 1.z	1. / hugez	huge / 1.z
1. / mhugez
mhuge / 1.z
1. ** hugez
huge ** 1.z1. ** mhugezmhuge ** 1.zmath.sin(huge)zmath.sin(mhuge)zmath.sqrt(huge)zmath.sqrt(mhuge)z(float(shuge) should not equal int(shuge))rLrr9rr�r�eval�assertNotEqual)r=rr�r�r��	namespace�testrrr�test_float_overflow�s�zLongTest.test_float_overflowcCs�t�tj�}ttd��gd�D] }d|}t�|�}|�||�||}t�|�}|�||�qdd>ddfD]}|�ttj|�|�ttj|�q9dS)Nr_)r`���'rr�rr)	r�log10�erVrE�assertAlmostEqual�logr�r�)r=�LOG10Er1r�r�r�r��badrrr�	test_logss

�zLongTest.test_logsc

s�|j}G�fdd�d��gd�}dD]!}|�|d|d||d|dt|d�t|�t|d�g�q|�ddd	tjttj�g�td
�}|�ddd	dd>|d||dg�|�dd
�|D��|D]r}�|�}|D]i}�|�}||k||k}|j|||d��K||k||k}	|||	�|||k|dk�|||k|dk�|||k|dk�|||k|dk�|||k|dk�|||k|dk�Wd�n1s�wYqlqddS)NcsHeZdZdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)z)LongTest.test_mixed_compares.<locals>.Ratc	Ss,t|t�r
||_d|_dSt|t�r�t�t|��\}}|dks-d|kr*dks-J�J�d}d}|rct�||�}t|�}||?dksEJ�||>|B}||8}d|krZdks]J�J�||8}|s3|dkrn||>}d}n|}d|>}|dkr||}||_||_t|�t|�|ks�J�dSt	d|��)Nrrr6r��rzcan't deal with %r)
�
isinstancer9r r0rr�frexpr'rr�)	r=r��fr��CHUNK�toprar r0rrr�__init__s8


$�

z2LongTest.test_mixed_compares.<locals>.Rat.__init__cs<t|��s	�|�}|j|j|j|j}}||k||kS)N)r�r r0)r=�otherrrK��Ratrr�_cmp__Fs
z0LongTest.test_mixed_compares.<locals>.Rat._cmp__cSs|�|�dkS�Nr�r��r=r�rrr�__eq__K�z0LongTest.test_mixed_compares.<locals>.Rat.__eq__cSs|�|�dkSr�r�rrrr�__ge__Mrz0LongTest.test_mixed_compares.<locals>.Rat.__ge__cSs|�|�dkSr�r�rrrr�__gt__Orz0LongTest.test_mixed_compares.<locals>.Rat.__gt__cSs|�|�dkSr�r�rrrr�__le__Qrz0LongTest.test_mixed_compares.<locals>.Rat.__le__cSs|�|�dkSr�r�rrrr�__lt__Srz0LongTest.test_mixed_compares.<locals>.Rat.__lt__N)
r�r�r�r�r�rrrrrrr�rrr�s(r�)rg����MbP?g�G�z��?r�g�?g@��x�D�Zb���ti)g�BgCg@Cr�g333333�?rrrri NcSrrrr	rrrr
arz0LongTest.test_mixed_compares.<locals>.<listcomp>)rrK�Rcmp)rLrer9r�maxsizerrM)
r=rN�cases�tr�RxrK�Ryr�xycmprr�r�test_mixed_comparess:9�$
����zLongTest.test_mixed_comparescCs�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd	�d
�|�tdd	�d�|�tdd
�d�|�tdd
�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�td d�d
�|�td d�d
�|�ttd!d"�d�d!�|�ttd!d"�d�d#�|�ttd!d"�d�d$�|�ttd!d"�d�d%�|�ttd&d'�|�td&d(�d)�|�td&d*�d+�|�tdd,�d�|�td d,�d
�|�tdd,�d-�|�tdd,�d.�|�tdd/�d-�|�tdd/�d.�|�tdd0�d1�|�tdd0�d.�|�tdd2�d3�|�tdd2�d.�|�ttd&d4�|�td&d5�d6�|�tdd7�d8�|�td d7�d9�|�tdd7�d:�|�tdd7�d;�|�tdd<�d:�|�tdd<�d;�|�tdd=�d>�|�tdd=�d;�|�tdd?�d@�|�tdd?�d;�|�ttd&dA�|�tdBdC�dD�|�ttddE�|�ttddF�|�ttddG�|�ttddH�|�tdItddJ�|�tdItddK�|�tdItddL�|�tdItddM�|�tdNtddO�|�tdPtddQ�dRdS�ttdT�tdU�d�D�dVdS�ttdW�tdX�d�D�D]5}|dYv�r�|�ttdZ|�|�ttd|�|�ttd|�|�ttd[d\|�|�ttd[d\|��qpd]D]}d^D]}|�t||�tt|�|���q��q�dS)_Ni�[r0�	123456789�,z123,456,789�_�123_456_789rro�1rz-1z-3z  1z -1z+3z +1z 3r�z 1rUr�3�Xi��4d2i.���z-4d2�8xz     4d2z    -4d2����beru�BEz-bez-BE���Iz,x�_x�	4996_02d2�_X�	4996_02D2�o�2322z-2322z-oz oz 2322z+oz+2322z,o�_o�
111_4540_1322r.�11z-11�10011010010z-10011010010z-bz bz 10011010010z+bz+10011010010z,b�90�_b�11_0000_0011_1001z1.3�_cz,cz+czCannot specify bothz_,z,_z_,dz,_dzCannot specify ',' with 's'z,szCannot specify '_' with 's'�_scS�g|]}t|��qSr��chrr	rrrr
�rbz+LongTest.test__format__.<locals>.<listcomp>r-rkcSr,rr-r	rrrr
�rb�A�ZzbcdoxXeEfFgGn%rrr`zeEfFgG%)rrrr`���ri.�i�)	rLr�r9r�r��assertRaisesRegexrE�ordr)r=�format_specr�rrr�test__format__qs��
����zLongTest.test__format__cCs:|�tttd��|�tttd��|�tttd��dS)N�infz-inf�nan)r�rr9rr�r�rrr�test_nan_inf�szLongTest.test_nan_infcCs�|�t��dd}Wd�n1swY|�dd�|�dd�|�dd�|�dd�|�dd�|�dd�|�dd�|�dd�dS)NrrrUr���r�r�r(rL�r=rrrr�test_mod_division�s
�zLongTest.test_mod_divisioncCs�dd>}|}|�||d�|�||d�|�||d�|�||d�|�d|d�|�d|d�|�d|d�|�d|d�|�d||d?|d�|�d||d?|d�|�d||d?|d�|�d||d?|d�|�||d>d	�|�d
||d
�||d�}dD]
}|�tt||�q�d
D]}t||�}|�|dd|�q�dD]
}|�tt||�q�dS)Nri@�r�r�ri�gԄ@gԄ�r6i@B)r�r�)r�r�zhuge / 1zhuge / 2z	huge / -1z	huge / -2zmhuge / 100zmhuge / 200)z1 / hugez2 / hugez	-1 / hugez	-2 / hugez100 / mhugez200 / mhugezexpected underflow to 0 from %r)zhuge / 0z	mhuge / 0)rLr�rr�r()r=r�r�r�r��	underflowr3�zerorrr�test_true_division�s6

��zLongTest.test_true_divisioncCs�|�t��dd}Wd�n1swY|�dd�|�dd�|�dd�|�dd�|�dd�|�dd�|�dd�|�dd�|�dd�|�dd�|�dd�|�dd�dS)NrrrrUr�rr:r;rrr�
test_floordivs
�zLongTest.test_floordivTc
Cs�|rtt|�t|��dtkrdSz	tt||��}Wnty%d}Ynty/d}Ynwzt||�}WntyCd}YntyMd}Ynw|�||d�||||��dS)z�Verify that the result of a/b is correctly rounded, by
        comparing it with a pure Python implementation of correctly
        rounded division.  b should be nonzero.rNr��zerodivisionz7Incorrectly rounded division {}/{}: expected {}, got {})	rr'r+r�r4rr(rLr�)r=r-r.�
skip_smallr�rrrr�
check_truedivs&	��
�zLongTest.check_truedivcCs�|�dd�|�dd�|�dd�|�dd�|�dd�|�ddtd�|�dd	dtt�|�ddd
d�|�ddd
d�dtttttf}|D]8}t|d|d�D],}|�ddt|d�ddt|d��|�ddt|d�ddt|d��q^qSddd
ddd
d
dddddddfD]}tdd�D]}|�|t||�|�|t||�q�q�td�D]}|�dtddddd|dtd�q�|�dd�|�d d!�td"�D]}|�d|dd|�|�d|d|d�q�ddd#d
d$d%dd&dd
d
dddddddfD]}tdd�D]}|�dt|||��q'�q td'd(�D]}|�|dd)��q>d*dd
dd"fD]7}td"�D]/}t�d|�}t�|d|d�}	|�||	�|�||	�|�||	�|�||	��qY�qStd+�D]9}
t�d"�}t�dd"�}t�d|�}
t�dd|�}|�|
|�|�|
|�|�|
|�|�|
|��q�dS),N�{ri8���rUrige~rr'iNFr`íl90r�Qri0&iCr�rr���i��i����)�2���r_���i�
l�E,J_l�J�br�rrtru� i���i4ld(	r�)	rCr�r+r*rErr)r:�	randrange)r=�basesr{r1�mr rH�Mr-r.r�a_bits�b_bitsrrKrrr�$test_correctly_rounded_true_division8sx�*,���"
����	
�z-LongTest.test_correctly_rounded_true_divisioncCs�|�t��dd>Wd�n1swY|�t��ddd>>Wd�n1s0wY|�t��dd?Wd�n1sIwY|�t��ddd>?Wd�dS1sfwYdS)Nr�rrr�)r�r�r�rrr�test_negative_shift_count�s
��
�"�z"LongTest.test_negative_shift_countcCs�|�dd�|�dd�|�t��dd>Wd�n1s wY|�ddd>>d�|�t��ddd>>Wd�dS1sGwYdS)Nrrrr�)rLr�r�r�rrr�test_lshift_of_zero�s
�"�zLongTest.test_lshift_of_zerocCs,|�dtj>d�|�dtjd>d�dS)Nrr�rLrr	r�rrr�test_huge_lshift_of_zero�sz!LongTest.test_huge_lshift_of_zeror�g�?F)�memuse�dry_runcCs$|�dtjd>dd>tj>�dS)Nrr�rX)r=�sizerrr�test_huge_lshift�s$zLongTest.test_huge_lshiftcCs,|�ddd>?d�|�ddd>?d�dS)Nr�rr�ri���r)rLr�rrr�test_huge_rshift�szLongTest.test_huge_rshift��g�?cCsJdd>dtj>}|�|tjd?dd>d�|�|tjd?d�dS)Nrr_r�i�r^r�r)rr	rL)r=r\r�rrr�test_huge_rshift_of_huge�sz!LongTest.test_huge_rshift_of_hugecCs>dd}|d}|d}|�||d�|�||d�dS)Nrr`r)�assertIs)r=r-r.�crrr�#test_small_ints_in_huge_calculation�s

z,LongTest.test_small_ints_in_huge_calculationcCs�tdd�D]a}|�||d�|�||d�|�||d�|�||d�|�||d@�|�||dB�|�||dA�|�||�|�||d�|�|tt|���|�||d>d?t|��qd}|�||d�|�d|d�dS)NrGirrrrl)rErar9r�)r=rHrrr�test_small_ints�szLongTest.test_small_intscCs�d}tdd�D]P}|��}|�|tt|��d���|dkr6|�d|dt|�ko1d|kn�n|�|d�|dkrW|�|dt�	t�
t|��t�
d�|��q|�d��d�|�d��d�|�d��d�|�d��d�|�d	��d�d
D]H}d|}|�|d��|�|�d|��|�|�|��|d�|�|��|d�|�|d��|d�|�|d��|d�q�dS)Ng�����|�=i��i�z-0brrrrr)rrUrrurF�rM�!�?�@��)rErrL�lenr��lstripr<r'r�floorr�)r=�tinyr�krHr-rrr�test_bit_length�s40���zLongTest.test_bit_lengthcCs�tdd�D]}|�|��t|��d��qdD]0}d|}|�|��d�|�|d��|�|�|dA��d�|�|dd	A��|d
�qdS)Ni���r�r)r_rFrgrh�Ai�iZi��rrrgri�rt)rErL�	bit_countr��count)r=r-r1rrr�test_bit_count�s�zLongTest.test_bit_countcCsidd�dd�dd�dd�dd�dd�dd�d	d�d
d�dd�dd�dd�d
d�dd�dd�dd�dd�dddd��}tddd�D]$}|��D]\}}t||d�}||}|�||�|�t|�t�qGqA|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�tdd�d�|�td d�d�|�td!d�d"�|�td#d�d"�|�td$d�d%�|�td&d�d%�|�td'd�d(�|�td)d*�d+�|�td,d*�d-�|�td.d�d/�|�td.d�d0�|�td.d*�d1�|�td.d2�d3�|�td.d4�d5�|�td.d6�d7�|�td.d8�d9�|�td.d:�d;�|�td.d<�d=�|�td.d>�d?�|�td.d@�d�|�td.dA�d�|�td.dB�d�tdd"�D] }td|dCd*�}d|dD}|�||�|�t|�t��qytd�D]$}td"�D]}	t�dEdF�}
t|
|�}|�||
�|�t|�t��q��q�dGdHdIdJdd"dd"fD]}|�tdK|�dK��q�td"�D]}	t�dEdF�}
t|
�}|�||
�|�t|�t��q�dL}|D]}
|�	t
td|
��qdS)MNrrrrUrr^r�r_rrtr�r�r�r�rTrrNru)rF��i����irij���ri8���ik���r1i���i���i����1rI�3r`��rLrK�i,iԡri�i��i��l!l!l�~!l�!r�l�!rGl`!i����l!r9l'�!i����lz+i����lv|orJl,Gxi����i�i���iF�i��i���r�r�r�r�r�i{�)�brianr�y)rE�items�roundrLra�typer9r:rOr�r�)r=�	test_dict�offsetrnr�rr��expectr rHr�huge_n�
bad_exponentsr�rrr�
test_rounds�&�������������
��zLongTest.test_roundcs<d<�fdd�	}idd�dd�dd	�d
d�dd
�dd�dd�dd�dd�dd�dd�dd�dd�dd�d d!�d"d#�d$d%�}||d&d'd(�idd�dd�dd	�d
d�dd
�dd�dd�dd)�dd*�dd�dd�dd+�dd�dd,�d d-�d"d.�d$d/�}||d0d'd(�dddd
d	ddd1d2d3d4�
}||d&dd(�dddd
d	d+dd,d2d5d4�
}||d0dd(��jtdjdd&dd(��jtdjdd&d'd(��jtdjdd0dd(��jtdjdd0d'd(��jtdjd6d&dd(��jtdjd6d0dd(���d�dd&�d7���d�d8d&�d9���d�d8d&�d:���djd8d&d'd(�d;���tdjdd&�dS)=NFcsb|��D]*\}}z��|jt|�||d�|�Wqty.}z
td�|||��|�d}~wwdS)N��signedz7failed to convert {0} with byteorder={1} and signed={2})r|rL�to_bytesrj�	Exception�AssertionErrorr���tests�	byteorderr�r�r��errr�rr�checkQs �
�����z%LongTest.test_to_bytes.<locals>.checkr�r�r�������r��������������������������������������s�����������������bigTr����������������little������)
rrr�r�r�r�r���r���r�r^sss������F)r�rr�rL)r=r��tests1�tests2�tests3�tests4rr�r�
test_to_bytesPs���������	�
���
�������������	�
���
��������zLongTest.test_to_bytescs�dM�fdd�	}idd�dd�dd�dd	�d
d	�dd�d
d�dd�dd�dd�dd�dd�dd�dd�dd�dd�d d!�d"d#d$d%d&��}||d'd(d)�idd�dd�dd�dd	�d
d�dd�d
d�dd�dd�d d�dd�d*d�d+d�dd�dd�d
d�dd!�d"d#d$d%d,��}||d-d(d)�ddd	dd.ddd!d/d#d0d1�}||d'dd)�ddd	dd.ddd!d/d#d0d2�}||d-dd)�Gd3d4�d4t�}��t|�dd'��|���|�dd'�d	���t|jdd'dd)��|���|jdd'dd)�d	���t|�dd-��|���|�dd-�d	���t|jdd-dd)��|���|jdd-dd)�d	���tjgd5�d'd(d)�d$���tjd5d'd(d)�d$���tjtd6�d'd(d)�d$���tjtd6�d'd(d)�d$���tjt�d7d6�d'd(d)�d$���tjtd6�d'd(d)�d$���t	tjdgd'���t	tjdgd8���t	tjdgd9���t
tjd:d'���t
tjd;d'���t
tjdd'���t
tjdd'd(���t
|jd:d'���t
|jd;d'���t
|jdd'���t
tjdd'd(�Gd<d=�d=t�}|�dd'�}��t|�|���|d>�Gd?d@�d@t�}	|	�dd'�}��t|�|	���|d	���t|dAdB�dC�GdDdE�dE�}
GdFdG�dG�}GdHdI�dI�}GdJdK�dK�}
dLD],}��t�|
�|�d	���t
tj|�|���t
tj|�|���ttj|
�|��q;dS)NNFcs^|��D](\}}z��tj|||d�|�Wqty,}z
td�|||��|�d}~wwdS)Nr�z9failed to convert {0} with byteorder={1!r} and signed={2})r|rLr9�
from_bytesr�r�r�r�r�rrr��s �
�����z'LongTest.test_from_bytes.<locals>.checkr�rr�sr�rr�r�rr�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�Tr�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�c@�eZdZdS)z'LongTest.test_from_bytes.<locals>.myintN�r�r�r�rrrr�myint�r�)r�rrr��Bzbigzlittlerr�c@r�)z(LongTest.test_from_bytes.<locals>.myint2cSst�||d�S)Nr)r9�__new__)�clsr�rrrr�9sz0LongTest.test_from_bytes.<locals>.myint2.__new__N�r�r�r�r�rrrr�myint28�r�rc@r�)z(LongTest.test_from_bytes.<locals>.myint3cSs
d|_dS)N�bar)�foo)r=r�rrrr�As
z1LongTest.test_from_bytes.<locals>.myint3.__init__N)r�r�r�r�rrrr�myint3@r�r�r��noner�c@r�)z,LongTest.test_from_bytes.<locals>.ValidBytescSr�)Nr�rr�rrr�	__bytes__Jr�z6LongTest.test_from_bytes.<locals>.ValidBytes.__bytes__N�r�r�r�r�rrrr�
ValidBytesIr�r�c@r�)z.LongTest.test_from_bytes.<locals>.InvalidBytescSr�)N�abcrr�rrrr�Mr�z8LongTest.test_from_bytes.<locals>.InvalidBytes.__bytes__Nr�rrrr�InvalidBytesLr�r�c@r�)z.LongTest.test_from_bytes.<locals>.MissingBytesNr�rrrr�MissingBytesOsr�c@r�)z.LongTest.test_from_bytes.<locals>.RaisingBytescSsdddS)Nrrrr�rrrr�Qsz8LongTest.test_from_bytes.<locals>.RaisingBytes.__bytes__Nr�rrrr�RaisingBytesPr�r�)r�r�r�)
r9rar~r�rL�	bytearray�array�
memoryviewr�r�r��getattrr()r=r�r�r�r�r�r�r�rHr�r�r�r�r��
byte_orderrr�r�test_from_bytes�st��������	�
���
��������������	�
���
�������
�
�
����
��
����
������zLongTest.test_from_bytescsFGdd�dt���fdd�td�D�}tt|�D]}|�|d�qdS)Nc@seZdZddd�ZdS)z<LongTest.test_access_to_nonexistent_digit_0.<locals>.IntegerrcSst�||�}d|_|S)Nr�)r9r�r�)r�r�r=rrrr�bszDLongTest.test_access_to_nonexistent_digit_0.<locals>.Integer.__new__N�rr�rrrr�Integerasr�csg|]}�d��qSr�rrw�r�rrr
grbz?LongTest.test_access_to_nonexistent_digit_0.<locals>.<listcomp>r�r)r9rE�maprL)r=�integersr rr�r�"test_access_to_nonexistent_digit_0]s
�z+LongTest.test_access_to_nonexistent_digit_0cCs@dD]}dD]}|�t||>�t�|�t||?�t�qqdS)N)TF)rr)rLr~r9)r=r�r%rrr�test_shift_boolks��zLongTest.test_shift_boolc	Cs�Gdd�dt�}ddddtjddd|d	�g}|D]$}|��\}}|�||ft|�df�|�t|�t�|�t|�t�qdS)
Nc@r�)z-LongTest.test_as_integer_ratio.<locals>.myintNr�rrrrr�sr�r�r_rrJrTFr�)r9rr	�as_integer_ratiorLr~)r=r�r�r��	numerator�denominatorrrr�test_as_integer_ratiors�zLongTest.test_as_integer_ratioN)T)3r�r�r�rDrIrSr]rfrhrjrlrnr}r�r�r�r�r�r�requires_IEEE_754r�r�r�rr5r8r<r?r@rCrUrVrW�cpython_onlyrY�
bigmemtestrr	r]r^r`rcrdrorsr�r�r�r�r�r�rrrrr5ssh'
		9
E\a"

[
	

"Jc+r5�__main__)#�unittestr�rrr:rr��int_info�bits_per_digitr8�BASErGrXrWrmrgrErHrYrrr�rr��min_expr*rr+r)rr4�TestCaser5r��mainrrrr�<module>sN
 .�

Youez - 2016 - github.com/yon3zu
LinuXploit